ebaccount
ebaccount

Reputation: 5051

How can I control showing of views on iPhone

Here is the scenario. I have 4 view controllers v1, v2, v3, v4 which are displayed using 4 tabbarcontroller of iPhone. now I push another view sv1 to v1 (while I am viewing v1, I use pushviewcontroller). Now if I press v2 tabbar (while I am viewing sv1), and then press v1 I see sv1. However, I do not want this behavior. I want to show v1 instead of sv1. How can I remove sv1 from its parent's view when v2 is clicked?

Thanks.

Upvotes: 0

Views: 193

Answers (2)

Dan Lorenc
Dan Lorenc

Reputation: 5394

You're confusing subviews and navigation controllers. When you push a view to a navigation controller, you push it to the end of a stack of views. The view at the end of the stack is displayed. You can pop that view from the stack, and the next view in the stack gets displayed:

[self.navigationController popViewController:YES];

With subviews, you have to remove then from their parent:

[sv1 removeFromSuperView];

In your case, you want the first solution.

Upvotes: 0

nevan king
nevan king

Reputation: 113747

Try using [navigationController popToRootViewController animated:NO] in your viewWillDisappear method.

Upvotes: 1

Related Questions