How to Dismiss 2 Modal View Controllers in Succession?

In B. Put:

[self dismissModalViewControllerAnimated:NO];
[self dismissModalViewControllerAnimated:YES];

Only run one animation.


Just found out you need to use presentingViewController in iOS 5.

[self.presentingViewController.presentingViewController dismissModalViewControllerAnimated:YES];

A -> B -> C

Running the above code in modal C will take you back to A


This worked for me, very simple

// Call inside View controller C    
self.presentingViewController?.dismissViewControllerAnimated(false, completion: nil)
self.presentingViewController?.dismissViewControllerAnimated(true, completion: nil)

Explanation:

If you call dismiss on C, it can only remove C. If you call dismiss on B, it will do the right thing: Remove the topmost modal view controller. The first call therefore removes C (with no animation). The second call removes B.

The easiest way to access view controller B from C is to use the presentingViewController variable.