我需要创建一个新的弹出视图,因为在编译时锚点在 Interface Builder 中不可见。
根据这个帖子 https://stackoverflow.com/questions/25319179/uipopoverpresentationcontroller-on-ios-8-iphone?lq=1,实现委托方法将在 iPhone 上强制 Popover。 (出于我不明白的原因)
正如帖子中所示,它在连续运行时效果很好。但我无法让它以非连续的方式工作。 (iPad 上确实会出现弹出窗口)
请帮忙!
代码如下:
func showOptions() {
let contentView = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("PasteOption") as NewPasteOptionViewController
contentView.modalPresentationStyle = UIModalPresentationStyle.Popover
contentView.preferredContentSize = CGSizeMake(200.0, 200.0)
presentViewController(contentView, animated: true, completion: nil)
var _popoverPresentationController = contentView.popoverPresentationController!
_popoverPresentationController.delegate = self
_popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirection.Any
_popoverPresentationController.sourceView = view
_popoverPresentationController.sourceRect = self.navigationItem.titleView!.frame
}
// this function below is never called.
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
return UIModalPresentationStyle.None
}
补充笔记:
呈现视图控制器在另一个视图中呈现为模态表单,并封装在导航控制器中。
所呈现的视图控制器是一个自定义表视图控制器。
看来是在动线presentViewController(contentView, animated: true, completion: nil)
到函数末尾即可解决问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)