2

Question

I have a .xib with a UIButton. That UIButton has a connection via Touch Up Inside to a method, - (IBAction)play:(id)sender, in the File's Owner.

When I run on a first-gen iPad the UIButton shows it's highlighted state when tapped, but doesn't call the connected method. I set a breakpoint at the first line of the method, and it's never hit.

When I run the app on a second-gen iPad, everything works properly.

I've hacked blindly at the issue a bit, but I'm hoping someone else has an insight to what might be going on. Any idea what I'm overlooking?

Update, partial solution

Thanks to Stavash's help, I see that the source of the issue is the gesture recognizer attached to the view containing the button.

When I remove the gesture recognizer, everything works.

I see a related question that indicates a solution using the UIGestureRecognizerDelegate to prevent the gesture recognizer from responding when the button is tapped.

However, even though the delegate method is returning NO when the button is tapped, the Touch Up Inside event still doesn't seem to be firing.

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
    if ((touch.view == self.playButton)) {
        return NO;
    }
    return YES;
}

code taken from related question, linked above

I'll experiment some more tomorrow, and post again if I figure out where I went wrong.

Community
  • 1
  • 1
NateK
  • 23
  • 4
  • Do both your devices have the exact same iOS version? There could be a difference there – Ismael Jan 31 '13 at 19:21
  • Are you using a UITapGestureRecognizer anywhere within the view controller? – Stavash Jan 31 '13 at 19:21
  • @Ismael, no they are different. iOS6 on the 2nd gen, iOS5 on the first gen. – NateK Jan 31 '13 at 19:33
  • @Stavash Yes. The main view of the .xib has a tap gesture recognizer, but it doesn't seem to be getting activated either. I can try removing it and seeing what happens. – NateK Jan 31 '13 at 19:35
  • @Stavash That was it, thank you. I'm surprised that the gesture recognizer "under" my button blocks it from receiving touch events. I'll do some more reading and see how to work around it. – NateK Jan 31 '13 at 20:28
  • Great to hear. Added it as an answer – Stavash Jan 31 '13 at 20:47

1 Answers1

1

Chances are (strange as it may seem) that you have an active UITapGestureRecognizer in that view controller that's reacting differently in each iOS version. Try cancelling any active instance of a gesture recognizer and see if it works.

Stavash
  • 14,244
  • 5
  • 52
  • 80