Reputation: 10930
I have 3 view controllers, presented modally, how do I dismiss the view controllers and go directly from the third right back to the first (root) view controller.
Basically, when I call dismissViewControllerAnimated
from the third I want it to also dismiss the underlying second view controller and return straight to the first view, releasing the others from memory.
EDIT
Simply, want to go from the third view on the right, back to the first without having to go through and dismiss the middle on. Obviously I can't just present the first one form the third, as thats a massive memory leak.
Upvotes: 3
Views: 1230
Reputation: 1288
Use NSNotificationCenter
for that.
You can post a notification when you want to dismiss all of your view controllers:
NSNotificationCenter.defaultCenter().postNotification("dismissNotification")
Then make these view controllers register to listen for such notifications in your viewWillAppear
function:
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("dismissFunction"), name: "dismissNotificaiton", object: nil)
Finally, you call dismissViewController:
in your dismissFunction
self.dismissViewControllerAnimated(true, completion: nil)
Upvotes: 1
Reputation: 5896
Try this :
self.dismissViewControllerAnimated(true, completion: nil)
Let me know if that what you needed :)
Upvotes: 0