简体   繁体   中英

Why doesn't the back button show up the second time I push the view?

Every time I click a picture I call this method (which pushes a view on the detail view):

-(IBAction) loadTeamView:(id)sender {
teamView = [[TeamViewController alloc] initWithNibName:@"TeamViewController" bundle:nil detailItem:self.detailItem];
[self.navigationController pushViewController:teamView animated:YES];
}

It works but if you click the back button (which automatically comes up) and then come back to this method no back button shows up. Any ideas?

Make sure you are not changing the content of the navigationItem property of the view controller. As per the documentation, the navigation controller follows the following rules for the left-hand side navigation bar button:

The bar button item on the left side of the navigation bar allows for navigation back to the previous view controller on the navigation stack. The navigation controller updates the left side of the navigation bar as follows:

  1. If the new top-level view controller has a custom left bar button item, that item is displayed. To specify a custom left bar button item, set the leftBarButtonItem property of the view controller's navigation item.
  2. If the top-level view controller does not have a custom left bar button item, but the navigation item of the previous view controller has a valid item in its backBarButtonItem property, the navigation bar displays that item.
  3. If a custom bar button item is not specified by either of the view controllers, a default back button is used and its title is set to the value of the title property of the previous view controller—that is, the view controller one level down on the stack. (If there is only one view controller on the navigation stack, no back button is displayed.)

http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM