这是我的PopOver代码。我有两个视图控制器。我在消息传递视图控制器中呈现PopOver,并且需要管道的视图控制器是PreferencesView控制器。故事板ID也是相同的首选项视图控制器。 popOver是成功的,但总是覆盖整个屏幕。即使UIModalPresentationStyle.None。我在这里做错了什么?PopOver视图控制器覆盖全屏
func optionClicked(sender:UIBarButtonItem)
{
print(")show set preference and set reminder option")
let preferenceAction: UIAlertAction = UIAlertAction(title: "Set preferences", style: .Default) { action -> Void in
self.optionChoosed(true)
}
let reminderAction: UIAlertAction = UIAlertAction(title: "Set reminder", style: .Default) { action -> Void in
self.optionChoosed(false)
}
let actionSheetController: UIAlertController = UIAlertController(title: kAlertTitle, message: "What you want to do?", preferredStyle: .ActionSheet)
let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in
}
actionSheetController.addAction(preferenceAction)
actionSheetController.addAction(reminderAction)
actionSheetController.addAction(cancelAction)
self.presentViewController(actionSheetController, animated: true, completion: nil)
}
func optionChoosed(isSetPreference:Bool)
{
if(isSetPreference)
{
print("Set preference")
let storyboard : UIStoryboard = UIStoryboard(name: "Messaging", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("PreferencesViewController") as! PreferencesViewController
vc.modalPresentationStyle = UIModalPresentationStyle.Popover
let popover: UIPopoverPresentationController = vc.popoverPresentationController!
popover.barButtonItem?.action = "isSetPreference"
popover.delegate = self
presentViewController(vc, animated: true, completion:nil)
}
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
return UIModalPresentationStyle.None
}
func dismiss() {
self.dismissViewControllerAnimated(true, completion: nil)
}
其中从optionChoosed调用实现这个功能呢?当你点击栏按钮时会弹出PopOver? – Sahil
是的,我有两个动作在酒吧按钮 – Niroj
你可以显示完整的代码? – Sahil