Anyoone can help me on how to add action to call the following method using UIButton
.
-(void)navigatePics:(id)sender andIndex:(NSInteger *)index{}
Use the button.setTag:(NSInteger) method to add the index to the UIButton as a tag.
UIButton *button = ...;
[button setTag:1234];
[button addTarget:self action:@selector(navigatePics:) forControlEvents:UIControlEventTouchUpInside];
Then in navigatePics, read the tag.
-(void)navigatePics:(UIButton *)sender
{
int index = sender.tag;
// index = 1234;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With