的UIBarButtonItem不点击

问题描述:

rootViewController反应后,我浏览到一个UIViewController的UIBarButtonItem不点击

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我有

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

我加入了签名.h文件的方法。 在.xib文件中,我有一个UIToolbarUIBarButtonItem。我将按钮连接到文件的所有者 - goBack

所有内容都出现在屏幕上,但是当我单击按钮时,goBack未被调用。我也试图用编程方式来做这件事,但我得到了同样的结果 - 一切都出现了,但对点击没有任何反应。

任何想法,为什么它不工作?

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

+0

@Adriana Post Button声明代码 – Rams 2011-06-09 12:53:52

+0

添加一行以检查发件人== UIBarButtonItem – Legolas 2011-06-09 14:09:40

+0

您是否尝试过在'goBack'方法中插入对'NSLog'的调用,或者在其中设置断点以查看它是否为没有叫,或者如果它没有效果? – marzapower 2011-06-09 14:16:33

是否将您的工具栏与文件所有者绑定?
由于您的UIBarButton是UIToolbar的子视图,因此您必须将工具栏与文件所有者绑定。

+0

工具栏位于视图内,视图绑定到文件的所有者。无论如何,我创建了一个IBOutlet UIToolbar并绑定它来查看它是否可以解决问题,但事实并非如此。 – Adriana 2011-06-09 13:40:33

+0

什么是self.contr类型? – dks1725 2011-06-09 13:59:55

+0

它是UIViewController的一个子类。 – Adriana 2011-06-09 14:24:41

呈现模态视图控制器不要求您通过UINavigationController。我建议你可以改变:

[self.navigationController presentModalViewController:self.contr animated:YES]; 
[self.navigationController dismissModalViewControllerAnimated:YES]; 

这样:

[self presentModalViewController:self.contr animated:YES]; 
[self dismissModalViewControllerAnimated:YES]; 

让我知道,如果这有助于。

+0

我试过了,但我没有达到goBack:无论如何。 – Adriana 2011-06-09 14:23:59

试试这个在GoBack方法:

[self.navigationController popToRootViewControllerAnimated:YES]; 

如果你不打,这意味着你没有在厦门国际银行正确连接它们的断点。