2013-04-26 59 views
-1

我隐藏了导航栏,所以我可以在那里有一个自定义的UIToolBar,但是当我将工具栏项目的action属性设置为弹出它的方法时,它不起作用,我认为这可能是因为我隐藏了导航栏。弹出视图控制器关闭堆栈没有导航栏显示?

这里是我的代码:

[toolBarItems addObject:[[UIBarButtonItem alloc] initWithTitle:@"Articles" style:UIBarButtonItemStyleBordered target:nil action:@selector(backButtonTapped)]]; 

...

- (void)backButtonTapped { 
    [self.navigationController popViewControllerAnimated:YES]; 
} 

但没有任何反应。

+0

你是什么意思隐藏导航栏?检查并查看您的导航控制器是否为 – JeffN 2013-04-26 18:50:08

+0

[self.navigationController setNavigationBarHidden:YES animated:NO]; – 2013-04-26 18:52:07

+0

不,不是零。 – 2013-04-26 18:52:44

回答

0

我在UIBarButton上截取了水龙头的整个视图上都有一个UITapGestureRecognizer。我解决了它,归功于this answer,它基本上停止了UITapGestureRecognizer的开始,除非它在UIToolBar之外。

3

你的选择器的目标是零,当它应该是自己的,你需要把发送者参数放在你的动作方法中!

[toolBarItems addObject:[[UIBarButtonItem alloc] initWithTitle:@"Articles" style:UIBarButtonItemStyleBordered target:self action:@selector(backButtonTapped:)]]; 

-(void) backButtonTapped: (id) sender { 
    //code as before here 
} 

编辑作为@sulthan指出,发件人参数需要!你可以像以前一样将它保留下来!

+0

这并没有改变任何东西。 – 2013-04-27 02:23:08

+0

请给popViewcontrollerAnimated:方法添加一个断点,并告诉我们它是否在点击按钮时被点击。 – Mario 2013-04-27 06:31:45

+0

它不被调用。 – 2013-04-27 18:09:10

相关问题