[英]BarButton item with different behaviours
在当前的应用程序中,我有三个UIViewControllers,并且正在使用StoryBoard:
ViewController,MenuViewController,CategoriasListViewController。
为了从ViewController显示MenuViewController,我正在使用按钮动作。 为了从MenuViewController返回到ViewControler,我正在使用带有以下操作方法的BarButton项:
- (IBAction)backButton:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
为了从MenuViewController显示CategoriasListViewController,我还使用了按钮动作。 为了从CategoriasListViewController返回到MenuViewControler,我将使用具有以下操作方法(与上面相同)的BarButton项:
- (IBAction)backButton:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
但是在这种情况下,不显示MenuViewController,BarButton操作将被忽略。
我使用自定义的BarButton动作而不是默认的“后退”按钮,因为在标题背景中,我有一个带有徽标的图像,该徽标会与默认的“后退”按钮重叠。 欢迎任何帮助。 谢谢。
更新1:这是我的StoryBoard:
我在阅读故事板时遇到困难,但是我很确定,如果您在方法中添加了一个断点- (IBAction)backButton:(id)sender
您将达到该断点。
我很确定当您按下按钮时该方法正在被调用(除非您忘记钩住它)。
该问题看起来像是将CategoriasListViewController
包装在全新的Navigation控制器中。 因此,当-backButton:
get调用时,您是在与该新NavigationNavigator对话,而不是您真正要-backButton:
对话的原始-backButton:
。
删除第二个不必要的UINavigationController,它应该可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.