swift – modalPresentationStyle .overCurrentContext导致在呈
我在tvOS视图控制器上使用.overCurrentContext modalPresentationStyle时遇到问题:
let vc = UIStoryboard(name: "",bundle: Bundle.main).instantiateInitialViewController() //representative of actually presented VC vc.modalPresentationStyle = .overCurrentContext present(vc,animated: true,completion: nil) 在呈现的视图控制器上,按下菜单按钮将停止返回到呈现视图控制器.将其设置为.overFullScreen和.blurOverFullScreen时也会发生这种情况.但是,在将其设置为.currentContext或.fullScreen时,我没有遇到此类问题.使用某些UIModalPresentationStyle时是否需要使用任何特定的东西? 解决方法let vc = UIStoryboard(name: "",bundle: Bundle.main).instantiateInitialViewController() //representative of actually presented VC vc.modalPresentationStyle = .overCurrentContext self.definesPresentationContext = true //*** adding this line should solve your issue *** self.present(vc,completion: nil) 那么这里发生了什么?在iOS 8中添加了definesPresentationContext属性,文档说明了以下内容:
通过将definesPresentationContext设置为YES,可确保要呈现的控制器显示在原始视图控制器的边界内. 快乐的编码! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |