0

I am stuck in a small problem,

I dynamically create a UIBarButtonItem using this code..

UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(didSelectPopitDownFromNavBar:)];

self.navigationItem.rightBarButtonItem = rightButton;

and the selector method is this..

-(IBAction)didSelectPopitDownFromNavBar:(id)sender event:(UIEvent *)event

so it gives a crash on click.. how can i pass this event..?

rmaddy
  • 307,833
  • 40
  • 508
  • 550
Ahmed Z.
  • 2,321
  • 22
  • 52

2 Answers2

5

All of the parameters form part of the method signature, so your button would need to use:

@selector(didSelectPopitDownFromNavBar:event:)

but this probably isn't going to do what you want as the button will only expect to pass itself (as the sender).

Wain
  • 118,043
  • 14
  • 134
  • 151
2

If your function was

UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(didSelectPopitDownFromNavBar:)];
...
-(IBAction )didSelectPopitDownFromNavBar:(id)sender

It shouldn't crash, the problem is likely the selector isn't properly defined,

see this question - Passing parameters on button action:@selector

Community
  • 1
  • 1
Dave S
  • 3,287
  • 1
  • 19
  • 33