开发者

UIBarButtonItem action with parameter

开发者 https://www.devze.com 2023-03-17 22:56 出处:网络
I had some problem, i need to add an UIBarButtonItem who call a method named \"valider\" - (void) valider:(NSString*) firstParam

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


UIButtonBarItems 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消