我需要创建一个新的popover视图,因为锚在编译期间在Interface Builder中不可见.
根据this post,执行委托方法将迫使iPhone上的Popover. (原因我不明白)
当在帖子中显示的时候,它的效果很好.但是我不能让这个工作在非隔断的方式. (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 }
补充笔记:
呈现视图控制器在另一视图中呈现为模态表单,并封装在导航控制器中.
呈现的视图控制器是自定义表视图控制器.