重复使用相同的类时导航控制器不显示后退按钮 [英] Navigation controller not displaying back button when same class is reused

查看:108
本文介绍了重复使用相同的类时导航控制器不显示后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个基于导航的应用程序. 让我解释一下该应用程序. 在程序加载表视图中,将显示3个选项,例如:

I'm doing a navigation based application. Let me explain a little bit about the application. At the program load table view will show 3 options like:

  • 酒店
  • 餐馆
  • 咖啡馆

如果用户选择以上任何一个选项,它将导航到另一个表视图并显示子选项.并且它将继续上升到6到7级. 因此,我在tableView的类(Sales)的didSelectRowAtIndexPath:中创建了它自己的对象,并使用[self.navigationController pushViewController:myViewController animated:YES];创建了另一个视图并绑定了数据库中的数据.对我来说,这很好,但问题是.我没有自动显示在导航栏上的后退"按钮.

If a user selects any of the above options, it will navigate to another table view and show sub options. And it'll continue up-to 6 to 7 levels. So I in the didSelectRowAtIndexPath: of the tableView's class (Sales) I created it's own object and using [self.navigationController pushViewController:myViewController animated:YES]; I'm creating another view and binds data from the database. It's working fine for me, ut the issue is. I'm not getting the 'back' button that is automaticaly displays on the navigation bar.

我的实现是这样的

@implementation Sales

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  {
 Sales *myViewController  = [[Sales alloc] initWithNibName:@"Sales"];
 [self.navigationController pushViewController:myViewController animated:YES];
 //Do other stuffs here
}

@end

像这样,我正在显示所有级别.但是,当我在任何选项中浏览时,都没有后退按钮. (通常,如果我导航到"Hotel",它将在导航栏上显示一个detailView并显示一个后退"按钮,但在这种情况下不会发生). 我认为问题在于创建相同类的对象并显示它,但我不能创建这么多的类和视图(总共约43个级别). 如何解决此问题(如何在导航栏上显示后退按钮)? 我的方法是好的方法还是该问题的解决方案? 预先感谢.

Like this I'm displaying the all levels. But when I navigated inside of any option I didn't get a back button. (Usually if I navigates to Hotel it will show a detailView and shows a back button on the navigation bar, but in this case this is not happening). I think the issue is with creating objects of the same class and displaying it, but I can't create such a number of classes and views (about 43 levels total). How can I resolve this issue (How can I show back button on the navigation bar) ? Is my method is good one or Is there any alternative solutions for this issue? Thanks in advance.

推荐答案

您的用于推送相同类的视图控制器的方法很好.该错误必须在其他地方.

Your method to push a view controller of the same class is fine. The error must be elsewhere.

  • 检查视图控制器是否具有title.那是当子视图控制器可见时在后退按钮上显示的文本.如果该文本为nil,将没有后退按钮.
  • Check if the view controller has a title. That is the text that is shown on the back button when the child view controller is visible. If that text is nil there will be no back button.

这篇关于重复使用相同的类时导航控制器不显示后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆