[英]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. 确保您没有更改视图控制器的
navigationItem
属性的内容。 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:
导航控制器更新导航栏的左侧,如下所示:
- 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.
要指定自定义的左栏按钮项,请设置视图控制器的导航项的leftBarButtonItem属性。
- 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.
如果顶级视图控制器没有自定义的左键按钮项,但是前一个视图控制器的导航项在其backBarButtonItem属性中具有有效项,则导航栏将显示该项。
- 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.
如果两个视图控制器都未指定自定义栏按钮项,则使用默认的后退按钮,并且其标题设置为上一个视图控制器的title属性的值,即,视图控制器向下一级堆栈。 (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 http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.