【发布时间】:2014-12-29 07:13:21
【问题描述】:
我需要创建一个新的弹出视图,因为在编译期间在 Interface Builder 中看不到锚点。
根据this post,实现委托方法将强制 iPhone 上的 Popover。 (因为我不明白的原因)
如帖子所示,在 segue 上效果很好。但我不能让它以非 segue 的方式工作。 (弹出窗口确实出现在 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
}
补充说明:
呈现视图控制器在另一个视图中呈现为模态表单,并封装在导航控制器中。 呈现的视图控制器是一个自定义的表格视图控制器。
【问题讨论】: