我的导航栏中有这样的代码:
UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:@selector(self)];
self.navigationItem.rightBarButtonItem = myButton;
当实际按下它时,下一步要抓住什么?
我的导航栏中有这样的代码:
UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:@selector(self)];
self.navigationItem.rightBarButtonItem = myButton;
当实际按下它时,下一步要抓住什么?
你在这里设置了一个错误@selector(self)
。
您需要在这里放置您需要触发的实际功能:
UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:@selector(doSomeThing)];
而且当然:
- (void) doSomeThing{
}
这样做
UIBarButtonItem *Button=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(myAction:)];
self.navigationItem.leftBarButtonItem=Button;
- (void)myAction:(id)sender
{
//do ur actions
}