Reputation: 837
I have this function in an IBAction button:
I start off with a table with a button, when that button is pressed this takes place:
TabBarController *v = [[TabBarController alloc]
initWithNibName:@"TabBarController" bundle:nil];
[self.navigationController pushViewController: v animated:YES];
[v release];
On the second view there is another button which when pressed does this:
NSArray *array = [self.navigationController viewControllers];
[self.navigationController
popToViewController:[array objectAtIndex:1] animated:YES];
This causes the app to crash, and at index 0 it does nothing. Is this because the second page is not a UITable like the first?
I want to be able to move from UITable view to UIView back and forth, should I use addSubview
instead? I need the first view to have a navbar but the second shouldn't.
Upvotes: 1
Views: 420
Reputation: 646
simply add the following line in button code and it will work fine
[self.navigationController popViewControllerAnimated:YES];
Upvotes: 0
Reputation: 2083
I think the problem is that [array objectAtIndex:1]
is your current ViewController, so popping to the current view controller might be the reason of your crash (did not try it though)
So why don't you do:
[self.navigationController popViewControllerAnimated:YES];
Upvotes: 1