Reputation: 25701
I have code like this in my navigation bar:
UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:@selector(self)];
self.navigationItem.rightBarButtonItem = myButton;
What's the next step to grab when this is actually pressed?
Upvotes: 0
Views: 67
Reputation: 8402
Do like this
UIBarButtonItem *Button=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(myAction:)];
self.navigationItem.leftBarButtonItem=Button;
- (void)myAction:(id)sender
{
//do ur actions
}
Upvotes: 2
Reputation: 18470
You mad a mistake here by setting @selector(self)
.
You need to put here the actual function you need to fire:
UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:@selector(doSomeThing)];
And of course:
- (void) doSomeThing{
}
Upvotes: 2