Saturday, 18 February 2012

Passing Multiple Parameters on UIButton action

Hello EveryBody,

One can pass multiple parameters on a single UIButton action as:

Just Make a Subclass of UIButton and have the parameters you want to pass in it.

Now when using the UIButton just pass the values to these parameters and access those parameters there.
Example:

MyCustomButton *urButton = [[MyCustomButton alloc] init];
urButton.urArg = arg;
[urButton addtarget:self action:@selector(urBtnTapped:) forControlEvents:UIControlEventTouchUpInside];

//      Implementation Part of Selector
- (void)urBtnTapped:(id)sender {

               UIButton *btn= (UIButton*)sender;
               argType *arg = btn.urArg;
}

In This way one can get multiple arguments.

Thanks

No comments:

Post a Comment