0

我的导航栏中有这样的代码:

UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:@selector(self)];

self.navigationItem.rightBarButtonItem = myButton;

当实际按下它时,下一步要抓住什么?

4

2 回答 2

2

你在这里设置了一个错误@selector(self)

您需要在这里放置您需要触发的实际功能:

UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:@selector(doSomeThing)];

而且当然:

- (void) doSomeThing{

}
于 2013-10-08T06:07:04.207 回答
2

这样做


   UIBarButtonItem *Button=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(myAction:)];
   self.navigationItem.leftBarButtonItem=Button;


 - (void)myAction:(id)sender
    {
        //do ur actions 
    }


于 2013-10-08T06:09:33.130 回答