Search code examples
iphone-sdk-3.0uinavigationcontrolleruinavigationbar

How can we navigate back to previous view programmatically in iPhone?


I am working on iPhone application which based on navigation controller. for example there are 2 views here.

A (UITableViewController) and B (ViewController)

the quest is here. when user select an item in View A. The application will force navigation controller to hide navigation bar before push View B to be showed, like the statement below:

self.navigationController.navigationBarHidden = YES;
[self.navigationController pushViewController:controllerB animated:TRUE];

That is, View B is there. but How can available user to navigate back to View A without navigation bar? In this case, we will use a button 'back' to let user tap on it to navigate back to View A. Could you help me?


Solution

  • You can call the popViewControllerAnimated method:

    [self.navigationController popViewControllerAnimated:YES];