点击后UIBarButtonItem没有反应 [英] UIBarButtonItem not reacting after click

查看:420
本文介绍了点击后UIBarButtonItem没有反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

rootViewController 我导航到 UIViewController

if (self.contr == nil) {
    ExampleViewController *controller = [[ExampleViewController alloc] 
                                   initWithNibName:@"Example" 
                                   bundle:[NSBundle mainBundle]];
    self.contr = controller;
    [controller release];
}
[self.navigationController presentModalViewController:self.contr animated:YES];

在UIViewController中我有方法

In the UIViewController I have the method

-(IBAction) goBack:(id)sender {
    [self.navigationController dismissModalViewControllerAnimated:YES];
}

我将签名添加到.h文件中。
.xib 文件中,我有 UIToolbar ,带有 UIBarButtonItem 。我将按钮连接到文件所有者 - goBack

I added the signature to the .h file. In the .xib file, I have a UIToolbar with a UIBarButtonItem. I connected the button to the File's Owner - goBack:

屏幕上出现一切,但是当我点击时没有调用 goBack 按钮。我也尝试以编程方式执行此操作,但我得到了相同的结果 - 一切都出现了,但没有对点击的反应。

Everything appears in the screen, but when I click on the button, goBack isn't called. I also tried to do this programatically instead, but I got the same result - everything appears, but no reaction to the click.

任何想法为什么它不起作用?

Any ideas why it isn't working?

编辑:
我刚发现工具栏上有一些不可见的东西。如果我点击特定点(在工具栏上),则调用goBack :.由于我使用presentModelViewController导航到此屏幕,导航栏没有出现......但可能它就在那里,这就是隐藏工具栏的内容。

I just found out something invisible is over the toolbar. If I click on a specific point (over the toolbar), then goBack: is called. Since I navigated to this screen using presentModelViewController, the navigation bar isn't appearing... but probably it's there and that's what is hiding the tool bar.

推荐答案

如果你没有点击断点,这意味着你没有在xib中正确连接它们。

If you are not hitting the breakpoint that means you did not connect them properly in the xib.

这篇关于点击后UIBarButtonItem没有反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆