我已经以编程方式添加了一个弹出视图,当我单击弹出窗口中的按钮时,它将显示另一个警报视图控制器。但问题是我无法忽略最初添加的弹出视图。它仍然显示在警报视图后面。有人可以帮我解决这个问题吗?
使用以下代码,我创建了弹出视图。
let storyboard : UIStoryboard = UIStoryboard(name: "Main",bundle: nil)
let menuViewController: PopupViewController = storyboard.instantiateViewControllerWithIdentifier("Popup") as! PopupViewController
menuViewController.modalPresentationStyle = UIModalPresentationStyle.Popover
menuViewController.preferredContentSize = CGSizeMake(300, 275)
let popoverMenuViewController = menuViewController.popoverPresentationController
popoverMenuViewController?.delegate = self
popoverMenuViewController?.sourceView = self.view
// If wants the arrow head remove the below line code
popoverMenuViewController?.permittedArrowDirections = UIPopoverArrowDirection()
popoverMenuViewController?.sourceRect = CGRectMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds),0,0)
presentViewController(menuViewController,animated: true,completion: nil)
答案 0 :(得分:0)
这可能对你有帮助
let alertController = UIAlertController(title: "My alert", message: "some text...", preferredStyle: .Alert)
// .Default will dismiss the alert automatically
let myAlertAction = UIAlertAction(title: "Alert", style: .Default, handler: { (UIAlertAction) in
// Some stuff, present your other alert
// self.myMainViewController.presentViewController...
})
alertController.addAction(myAlertAction)
我就是这样做的,而且效果很好