开发者

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


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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜