【问题标题】:Pressing UIBarButtonItem on a NavigationController在 NavigationController 上按下 UIBarButtonItem
【发布时间】:2010-06-15 14:36:51
【问题描述】:

我在导航栏上添加了一个按钮,如下所示:

UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStylePlain target:self action:@selector(methodtocall:)];          

self.navigationItem.rightBarButtonItem = anotherButton;
[anotherButton release];

但是,当我按下此按钮时,我得到了 InvalidArgumentException。这是一个全新的导航项目。有谁知道我为什么会出现这种行为?

【问题讨论】:

  • 可以看看你的操作方法吗?

标签: iphone objective-c cocoa-touch uinavigationbar uibarbuttonitem


【解决方案1】:

你需要像这样定义你的动作方法:

-(void) methodtocall:(UIBarButtonItem *) sender {
   //do stuff...
}

您可能收到InvalidArgument 错误,因为您没有定义接收UIBarButtonItem 的方法。

【讨论】:

    猜你喜欢
    • 2018-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-28
    • 1970-01-01
    • 2016-04-05
    相关资源
    最近更新 更多