I am new to iOS and swift. I'm trying to show a popover. I have managed to show a popover but the problem is I need to dismiss it from the parent.
I can dismiss the popover from the ViewController itself using this code
self.dismissViewControllerAnimated(true, completion: nil)
But I need to do this from the parent view controller.
I have done this so far. On button click performSegueWithIdentifier("bookingPopOverSegue", sender: self)
on prepareForSegue,
if segue.identifier == "bookingPopOverSegue" {
var bookingViewController = segue.destinationViewController as! BookingViewController
var passthroughViews: [AnyObject] = self.timeSlotButtons
passthroughViews.append(self.scrollView)
bookingViewController.popoverPresentationController?.passthroughViews = passthroughViews
}
Any idea on how to do this? Any help would be appreciated..
Just call dismiss method using parent's presentedViewController property, like ....
self.presentedViewController.dismissViewControllerAnimated(true, completion: nil)
For Swift 3.0
self.presentedViewController?.dismiss(animated: true, completion: nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With