25

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?

Teerasej
  • 1,486
  • 4
  • 21
  • 31

3 Answers3

64

You can call the popViewControllerAnimated method:

[self.navigationController popViewControllerAnimated:YES];
Philippe Leybaert
  • 168,566
  • 31
  • 210
  • 223
0

Swift Version

self.navigationController?.popViewController(animated: true)
Abdul Saleem
  • 10,098
  • 5
  • 45
  • 45
0

Swift 3:

 _ = navigationController?.popViewController(animated: true)

From this post: Xcode 8 / Swift 3: "Expression of type UIViewController? is unused" warning

4b0
  • 21,981
  • 30
  • 95
  • 142