tags:

views:

142

answers:

2

Hi,

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.

+1  A: 

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

nevan
I have used that, it goes back to the previous screen but the navigation bar is not drawn at all.
ebaccount
A: 

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.

Dan Lorenc