Add a weak property to the child view controller, which should contain a reference to the parent view controller
class ChildViewController: UIViewController { weak var parentViewController: UIViewController? .... }
Then in your code (I assume it is inside your parent view controller)
let storyboard = UIStoryboard(name: "Main", bundle: nil) let vc = storyboard.instantiateViewControllerWithIdentifier("myChildView") as! ChildViewController vc.parentViewController = self self.presentViewController(vc, animated: true, completion: nil)
And, as vomako said, call the parent method before rejecting your child view controller.
parentViewController.someMethod() self.dismissViewControllerAnimated(true, completion: nil)
Or you can also call the method in the completion parameter of the offsetViewControllerAnimated function, where it will be launched after the child view controller rejects:
self.dismissViewControllerAnimated(true) { parentViewController.someMethod() }
source share