问题覆盖了iOS中的“后退”按钮 [英] Problem over-riding the Back button in iOS
本文介绍了问题覆盖了iOS中的“后退”按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个UITableViewController A,它将UITableViewController B推入堆栈。
I have a UITableViewController A that is pushing UITableViewController B onto the stack.
在A中,我有以下代码:
In A i have the code:
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Trending"
style:UIBarButtonItemStylePlain
target:self
action:@selector(backButtonClicked:)];
backButtonClicked:也已实现。
backButtonClicked: is also implemented.
B的标题为趋势,但是当我单击它时,它永远不会到达backButtonClicked:
B has the title Trending, but when I click it, it doesn't ever reach backButtonClicked:
这是为什么?
推荐答案
尝试设置委托:
[navigationController setDelegate:self];
或者使用向左按钮。有时后退按钮不适用于某些视图,而我不得不使用左按钮:
Or using the left button. Sometimes the back button doesn't work with certain views and I have had to use the left button instead:
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Trending" style:UIBarButtonItemStylePlain target:self action:@selector(backButtonClicked:)];
另外,您可以尝试设置B的按钮项,而不是A:
Also, you can try setting B's button item instead of A:
viewControllerB.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Trending" style:UIBarButtonItemStylePlain target:self action:@selector(backButtonClicked:)];
这篇关于问题覆盖了iOS中的“后退”按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文