[英]Dismiss Popover ViewController from Tableviewcell in Swift
[英]How to dismiss a popover from parent in swift
我是iOS和swift的新手。 我正试图展示一个弹出窗口。 我设法显示一个弹出窗口,但问题是我需要从父母那里解雇它。
我可以使用此代码从ViewController本身中删除popover
self.dismissViewControllerAnimated(true, completion: nil)
但我需要从父视图控制器执行此操作。
到目前为止我已经这样做了。 在按钮上单击performSegueWithIdentifier(“bookingPopOverSegue”,sender:self)
在prepareForSegue上,
if segue.identifier == "bookingPopOverSegue" {
var bookingViewController = segue.destinationViewController as! BookingViewController
var passthroughViews: [AnyObject] = self.timeSlotButtons
passthroughViews.append(self.scrollView)
bookingViewController.popoverPresentationController?.passthroughViews = passthroughViews
}
有关如何做到这一点的任何想法? 任何帮助,将不胜感激..
只需使用parent的presentViewController属性调用dismiss方法,就像....
self.presentedViewController.dismissViewControllerAnimated(true, completion: nil)
对于Swift 3.0
self.presentedViewController?.dismiss(animated: true, completion: nil)
如果弹出控制器是公共的(例如作为子视图控制器的属性),那么只需使用它:
// 'self' is the parent
// 'popoverController' is the name of the property
self.childViewController.popoverController.dismissPopoverAnimated(<true or false>)
换句话说,问题不在于弹出,而是从父级的可见性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.