重用表类时的栏按钮问题
我在我的应用程序中使用表视图。它的委托和数据源都在同一个类 RootviewController 中。 当用户单击单元格时,我重用同一类 RootViewController 来显示下一个包含内容的表格。用户可以在表格中单击导航 4 次,它将导航到下一个视图。 但不幸的是,当用户第一次单击时,它将导航到下一个表视图,但不会显示后退按钮。对于剩余的点击,它工作正常并显示后退按钮。用户也无法导航回第一个视图。
RootViewController *root = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
[root setNext:temp.previousCategory];
[root setTitle:temp.Category];
temp = nil;
[self.navigationController pushViewController:root animated:YES];
我对此完全感到困惑,请帮助我。
I'm using a table view in my app.It's Delegate and datasource all are in the same class RootviewController.
When user clicks a cell, I reuse the same class RootViewController for displaying next table with content. User can click to navigate for 4 times in the table and it'll navigate to next view.
But unfortunately when user clicks the first time, it'll navigate to next table view, but it won't display the back button. For the remaining clicks it works fine and displays the back button. Also user cannot navigate back to first view.
RootViewController *root = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
[root setNext:temp.previousCategory];
[root setTitle:temp.Category];
temp = nil;
[self.navigationController pushViewController:root animated:YES];
I'm totally confused about it, please help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许
您还可能必须为控制器的导航项指定一个标题,以便后退按钮有一些可显示的内容(在推动视图控制器之前执行此操作)
Maybe
Also you might have to give the navigation item of the controller a title so that the back button has something to display (do this before pushing the view controller)
您确实应该将代码的数据处理部分拆分为除 RootViewController 之外的单独的类或对象。
这样,您的代码可能会更易于管理,您将能够推送新的视图控制器,最重要的是,推送新视图将提供用户期望的“后退”按钮。
You really should split out the data handling part of your code into a separate class or object apart from the RootViewController.
That way, your code will likely be more manageable, you'll be able to push new view controllers, and most importantly, pushing new views will provide "back" buttons as the user would expect.