Guest
Guest

Reputation: 45

App Tab Bar Multiple View Crash

I have a tab bar app with multiple views on each tab. A button is pressed in a tab to take you to a different xib view. A button there is pressed to take you back to the first tab in the tab bar. The problem is when i press the button to go back, I don't want to go to the first view for the FirstViewController, I want to go the the mainwindow where the tab bar controller and stuff is. The button takes you to the firstview without the tab bar. If I change the code to initWithNibName@"MainWindow" it crashes when i press the button. What should I do?

Here is the code in question:

-(IBAction)back{ 
    FirstViewController *back = [[FirstViewController alloc] initWithNibName:@"MainWindow" bundle:nil]; 
    [self presentModalViewController:back animated:YES]; 
} //this is for going back 

-(IBAction)forward{ 
    test2 *forward = [[test2 alloc] initWithNibName:@"test2" bundle:nil]; 
    [self presentModalViewController:forward animated:NO]; 
} //this is for going to the view. by the way there are no errors or warnings, just "Debugging Terminated" when it crashes.

Upvotes: 1

Views: 271

Answers (1)

amattn
amattn

Reputation: 10065

You can't use presentModalViewController to go back or forward. Modal view controllers should be though of as temporary utility views.

If you are in a navigationController, then you have to use pushViewController:animated: to "drill down" and popViewController:animated: to go back.

Upvotes: 1

Related Questions