我一直收到此错误,因为我无法正确锚定我的segue。我尝试过混合使用故事板和编码。
我是iOS的新手,所以我一直试图通过查看this solution以及Youtube视频来解决这个问题。任何帮助将不胜感激!
答案 0 :(得分:1)
根据我的经验,以编程方式执行此操作更容易,并且一起忘记segue / storyboard。
这适用于swift 2.0
func showPopOverBox(button:UIButton) {
let popoverViewController = self.storyboard?.instantiateViewControllerWithIdentifier("yourviewcontrollerstoryboardId") as UIViewController!
popoverViewController.modalPresentationStyle = .Popover
popoverViewController.preferredContentSize = CGSizeMake(600, 600)
let popoverPresentationViewController = popoverViewController.popoverPresentationController
popoverPresentationViewController?.permittedArrowDirections = UIPopoverArrowDirection.Any
popoverPresentationViewController?.sourceView = button
popoverPresentationViewController?.sourceRect = button.bounds
presentViewController(popoverViewController, animated: true, completion: nil)
}
答案 1 :(得分:0)
这是Swift 3.0的答案:
func showPopOverBox(button:UIButton)
{
let popoverViewController = self.storyboard?.instantiateViewController(withIdentifier: "yourviewcontrollerstoryboardId") UIViewController!
popoverViewController?.modalPresentationStyle = .popover
popoverViewController?.preferredContentSize = CGSize.init(width: 600, height: 600)
let popoverPresentationViewController = popoverViewController?.popoverPresentationController
popoverPresentationViewController?.permittedArrowDirections = UIPopoverArrowDirection.up
popoverPresentationViewController?.sourceView = button
popoverPresentationViewController?.sourceRect = button.bounds
present(popoverViewController!, animated: true, completion: nil)
}