Support for UIBarButtonItem

advertisements

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?


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{

}