UIBarButtonItem action with parameter
I had some problem, i need to add an UIBarButtonItem who call a method named "valider"
- (void) valider:(NSString*) firstParam
{
NSLog(@"Logs %@", firstParam);
}
and i creat my UIBarButtonItem like this, but i need to pass my first parameter !
U开发者_运维问答IBarButtonItem *buttonValiderAddSerie = [[UIBarButtonItem alloc]initWithTitle:@"Valider" style:UIBarButtonItemStyleBordered target:self action:@selector(valider:)];
I tried this but it doesn't work for me...
UIBarButtonItem *buttonValiderAddSerie = [[UIBarButtonItem alloc]initWithTitle:@"Valider" style:UIBarButtonItemStyleBordered
[buttonValidAddSerie addTarget:self action:@selector(valider:) firstParam:@"first"];
Thank's for reading,
Tommy
UIButtonBarItem
s actions signature look like
- (void)didTapButtonBarItem:(id)sender;
The sender
parameter is a pointer to the button currently pressed.
You have to store your first
parameter elsewhere in your class, then retrieve it when you tap on buttonValidAddSerie
.
精彩评论