Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

popViewController not working

I am having an issue with popViewController.

I use pushViewController to go to OrdersFormViewController

OrdersFormViewController *ordersFormViewController = [[OrdersFormViewController alloc] initWithNibName:@"OrdersFormViewController" bundle:nil];

[self.navigationController pushViewController:ordersFormViewController animated:YES];
[ordersFormViewController release];

From OrdersFormViewController I display a UIAlertView in viewDidLoad and call popViewController but this is not working.

UIAlertView* alertView = [[UIAlertView alloc]
                         initWithTitle:@"Error"
                         message:@"Error"
                         delegate:self
                         cancelButtonTitle:@"OK"
                         otherButtonTitles:nil];
[alertView show];
[alertView release];

[self.navigationController popViewControllerAnimated:YES];

The view is not "popped" from the navigationController but when pushing the standard back button in the navigation bar, only the navigation bar changes and not the actual view.

Does anyone have an idea why this is happening?

like image 304
simonbs Avatar asked Apr 17 '26 23:04

simonbs


2 Answers

I had a similar problem I fixed it by using

[self.parentViewController.navigationController popViewControllerAnimated:YES];

Hope that helps.

like image 196
Tony Million Avatar answered Apr 19 '26 19:04

Tony Million


Not sure what you're trying to acomplish; but try adding it to viewDidAppear instead.

viewDidLoad may be getting called before you do the initial pushViewController call.

like image 22
Wex Avatar answered Apr 19 '26 21:04

Wex