所需的弹出输出:
我尝试按照教程here进行操作......但是,我似乎无法实现这一目标
当前代码:
func adaptivePresentationStyleForPresentationController(
controller: UIPresentationController!) -> UIModalPresentationStyle {
return .None
}
@IBAction func UploadClicked(sender: AnyObject)
{
let menuViewController = MenuViewController()
menuViewController.modalPresentationStyle = .Popover
menuViewController.preferredContentSize = CGSizeMake(50, 100)
let popoverMenuViewController = menuViewController.popoverPresentationController
popoverMenuViewController?.permittedArrowDirections = .Any
popoverMenuViewController?.delegate = self
popoverMenuViewController?.sourceView = sender
popoverMenuViewController?.sourceRect = CGRect(
x: location.x,
y: location.y,
width: 1,
height: 1)
presentViewController(
menuViewController,
animated: true,
completion: nil)
}
使用未解析的标识符menuviewcontroller
使用未解析的标识符位置
答案 0 :(得分:3)
你的问题与Popover的呈现没有任何关系,你的错误说:
使用未解析的标识符menuviewcontroller
您需要按以下方式实例化UIViewController
:
// Set the name of your Storyboard here
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
// Instantiate your UIViewController
let menuViewController = storyBoard.instantiateViewControllerWithIdentifier("MenuViewController") as! MenuViewController
在执行上述代码之前,您需要在Interface Builder中的IdentityInspector中设置 StoryBoardID ,如下图所示:
我希望这对你有所帮助。