导航控制器不添加后退按钮
我有一个视图将新视图推送到屏幕上。
当显示新视图时,导航控制器中没有后退按钮。
我在一个视图中有以下内容
我使用以下代码推送一个新视图
[photoViewController setAsset:[assets objectAtIndex:(cell.rowNumber * 4) + index]];
[[self navigationController] pushViewController:photoViewController animated:YES];
[photoViewController release];
当视图出现时以下是可见的
如何添加后退按钮以及在哪里添加相同的共享按钮到栏在第二个视图中?
谢谢。 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要在第一个视图中设置标题。后退按钮使用上一个视图的标题。如果未设置,则不会显示后退按钮。
在第一个视图的 viewDidLoad 方法中,使用 self.title = @"title";
You need to set a title in your first view. The back button uses the title of the previous view. If one is not set then the back button will not be displayed.
In the viewDidLoad method of your first view, use self.title = @"title";
奇怪的是,推送控制器的导航栏中没有显示后退按钮,因为这是标准的开箱即用行为,免费为您提供一个。您的 photoViewController 尚未覆盖
-(UINavigationItem*)navigationItem;
,是吗?至于将“共享”按钮添加到第二个控制器,您可以在加载视图时通过控制器的 navigationItem 属性来设置它:
您可以使用相同的方法来设置自定义后退按钮,只需为自己获取另一个 UIBarButtonItem 并设置它即可作为 UINavigationItem 的 leftBarButtonItem。
It's odd that there is no back button displayed in the navigation bar for the pushed controller, because it is standard, out-of-the-box, behavior to give you one for free. Your photoViewController hasn't overridden
-(UINavigationItem*)navigationItem;
, has it?As for adding the "Share" button to the second controller, you can just set it through the controller's navigationItem property when the its view loads:
You can use the same approach to set a custom back button, just get yourself another UIBarButtonItem and set it as the leftBarButtonItem of your UINavigationItem.
尝试在项目可执行文件的环境变量中使用 NSZombieEnable ,这将帮助您进行调试。通常会发生这种崩溃,因为数组包含的元素少于您指定的数量。我认为您需要使用此代码所以......
并且还将断点放入表视图方法中,在索引路径中选择行,在索引路径中选择行的单元格以及行数,希望您能够弄清楚
Try to use the NSZombieEnable in your enviornment variable in your projects executable ,this will help you to debug.Well this crash genrally occurs ,because array contains elements less then the count you are specifying.you need to work with your this code, i think so....
and also put the breakpoints in your table view method didselect row at index path,cell for row at index path and number of rows and hopefully you would be able to figure out
你不应该在 VIewDidLoad 上设置 backButton,而是在 DidSelect 上对其进行编码
U should not set backButton on VIewDidLoad, instead u code it on DidSelect