views:

27

answers:

2

Here's my view controller hierarchy:

| [A]
| ---- [A1]
| ---- [A2]

One accesses view controllers A1 and A2 by tapping A1 and A2 cells respectively within view controller A.

Say I have tapped through to A1, and within that view controller I press a button which brings me straight through to A2, how do I:

  1. Remove A1 as the visible view, and also relinquish it from memory.
  2. Show A2.
  3. Have it so that a back button appears on A2's navigation controller which brings the user back to A when tapped.

As a bonus question, can anyone recall a native iPhone application which does this kind of thing? You know, just so I can see how Apple handles it.

Thanks friends.

A: 

Depends on the relationships between the controllers but basically you have to pop A1 from the UINavigationController's stack and push A2 onto it.

tob
This doesn't work. Popping a view controller means you can no longer push from it. And pushing first means the hierarcy ends up like this `A` -> `A1` -> `A2`.
David Foster
You have to push from A. I don't see the problem here.
tob
+1  A: 

I think you can use same presentModalView and dismissis methods just specify withAnimation: NO. This way path in navigation controller will be correct.

And I don't recall seeing anything like this in standard apps... which may be a sign for you to re-think why are you trying to do this.

sha
Yep, I didn't think Apple apps did this. Thanks Sha.
David Foster