简体   繁体   English

为什么第二次按下视图时后退按钮不显示?

[英]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: 导航控制器更新导航栏的左侧,如下所示:

  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. 要指定自定义的左栏按钮项,请设置视图控制器的导航项的leftBarButtonItem属性。
  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. 如果顶级视图控制器没有自定义的左键按钮项,但是前一个视图控制器的导航项在其backBarButtonItem属性中具有有效项,则导航栏将显示该项。
  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. 如果两个视图控制器都未指定自定义栏按钮项,则使用默认的后退按钮,并且其标题设置为上一个视图控制器的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.

相关问题 UINavigationController中不显示“后退”按钮 - “Back” button doesn't show up in UINavigationController 当我单击IOS中的按钮时,为什么视图不显示? - Why the view doesn't show when I click the button in IOS? 为什么我无法使用“自动布局”使用渐变子图层来放置视图? 没有出现 - Why am I unable to position my view with a gradient sublayer with Auto Layout? It doesn't show up 为什么选项卡栏没有显示在我的视图控制器上? - Why doesn't the tab bar show up on my view controllers? 如果先前的视图控制器没有标题,则我的导航栏不显示后退按钮 - My navigationbar doesn't show a back button if the previous view controller has no title ViewController已加载,但视图未显示 - ViewController is loaded, but the view doesn't show up Xcode:我的用户位置在第一次运行模拟时没有显示,但是在第二次运行时显示 - Xcode: My user location doesn't show the first time I run the simulation but the second time it does 为什么我的导航栏不显示? - Why my navbar doesn't show up? 自定义工具栏不会显示在第一个视图上,但会显示第二次 - Custom Toolbar doesn't show up on first view but does 2nd time shown iOS-为什么不显示表格视图? - iOS - Why table view doesn't show?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM