[英]Dismiss a pop up view
我已经以编程方式添加了一个弹出视图,当我单击弹出窗口中的按钮时,它将显示另一个警报视图控制器。 但是问题是我无法取消最初添加的弹出视图。 它仍然显示在警报视图的后面。 谁能帮我解决这个问题?
使用以下代码,我创建了弹出视图。
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)
那可以帮助你
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)
这就是我的做法,并且效果很好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.