后栏未显示在导航控制器中
这是代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DrinkDetailViewController *detailViewController = [[DrinkDetailViewController alloc] initWithNibName:@"DrinkDetailViewController" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
[self.navigationController popToRootViewControllerAnimated:YES];
[DrinkDetailViewController release];
}
我想要一个后栏可以从详细视图转到我的根视图。我该怎么做?
Here is the code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DrinkDetailViewController *detailViewController = [[DrinkDetailViewController alloc] initWithNibName:@"DrinkDetailViewController" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
[self.navigationController popToRootViewControllerAnimated:YES];
[DrinkDetailViewController release];
}
I want to have a back bar to go to my root view from the detail view. How do I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里有两件事看起来有点奇怪...希望修复它们将使后退按钮显示出来:
据我所知,
UINavigationController
应该为您处理后退按钮。如果没有,我会检查您的 xib 中的所有内容是否正确连接(如果您有的话)。祝你好运!There's 2 things that look a little weird here... hopefully fixing em will make the back btn show up:
The
UINavigationController
should take care of the back button for you as far as I know. If not, I would check to see that everything is wired up correctly in your xib (if you have one). Good Luck!使用您的代码,它仍然会推送到 DrinkDetailViewController,但完全不需要 popToRootViewController。您应该删除如下行。
我相信,您的后退按钮没有显示在导航栏上的原因是因为您没有在根视图中放置任何标题。您可以将此代码放在根视图上的 viewdidload 方法上。
With your code, it will still push to the DrinkDetailViewController but the' popToRootViewController is totally unnecessary. You should delete the line like follows..
And I believe, the reason your back button does not show up on the nav bar is because you didn't put any title in your root view. You can put this code on you viewdidload method on the root view.