我需要创建一个新的弹出窗口视图,因为在编译期间,Interface Builder中的锚点不可见.
根据这篇文章,实现委托方法将迫使Popover在iPhone上.(由于我不明白的原因)
如帖子所示,它在segue上工作得很好.但我无法以非分段的方式使用它.(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
}
Run Code Online (Sandbox Code Playgroud)
补充说明:
呈现视图控制器在另一视图中呈现为模态表单,并封装在导航控制器中.呈现的视图控制器是自定义表视图控制器.
似乎将该行presentViewController(contentView, animated: true, completion: nil)
移至该函数的末尾将解决该问题.
| 归档时间: |
|
| 查看次数: |
4546 次 |
| 最近记录: |