I have three buttons set up in Interface Builder, each tied via touchUpInside to btnSelection:
- (IBAction)btnSelection:(id)sender {
NSLog(@"tag: %i", [sender tag]);
}
In my console, the first click registers correctly (after a second or so delay, which seems a bit weird) but any subsequent touch of any of the 3 buttons results in first logging the previous tag value, then logging the new tag.
Touch #1 (btn w/ tag=0):
tag:0
Touch #2 (btn w/ tag=1):
tag:0 tag:1
Touch #3 (btn w/ tag=2):
tag:1 tag:2
and so on.
I can't figure out why two events are being logged each time (with the first being the previously touched button.
One possible reason is that if you hooked up your button to the event, and then copied that button and hooked up the event again, you might be calling your btnSelection function twice.
In interface builder, check to see that you only have one callback to btnSelection
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