0

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

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

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

然而,当我按下此,我收到了InvalidArgumentException。这是一个全新的导航项目。有谁知道我为什么得到这种行为?

+0

我们可以看到您的操作方法吗? – 2010-06-15 14:41:24

回答

1

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

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

你可能会得到一个错误InvalidArgument因为你没有定义方法来接收UIBarButtonItem

相关问题