+1  A: 

Hi Kevin,

Prior to iPhone OS 3.0, the UIScrollView's hitTest:withEvent: method always returns self so that it receives the UIEvent directly, only forwarding it to the appropriate subview if and when it determines it's not related to scrolling or zooming.

I couldn't really comment on iPhone OS 3.0 as it's under NDA, but check your "iPhone SDK Release notes for iPhone OS 3.0 beta 5" :)

If you need to target pre-3.0, you could override hitTest:withEvent: in BeachView and set a flag to ignore the next beach touch if the CGPoint is actually in a stone.

But have you tried simply moving your calls to [super touches*:withEvent:] from the end of your overridden methods to the start? This might cause the stone tap to occur first.

H

hatfinch
I moved [super] to the start of the methods and it made a difference. It still registers two taps but at least now it's saying 1-beganBeach 2-beganStone 3-endedBeach 4-endedStone, so there's time to pop a flag in there.I was just looking around at hitTest but when it started talking about CAlayers vs UIviews it seemed like a book I just wasn't quite ready to open. I'll give it another shot.Thanks Hatfinch, -k.
Kevin Beimers
Alrighty, I can work with this.Thanks again, -k.
Kevin Beimers
A: 

Is true, iPhone SDK 3.0 and up, don't pass touches to -touchesBegan: and -touchesEnded: UIScrollviewsubclass methods anymore. You can use the touchesShouldBegin and touchesShouldCancelInContentView methods that is not the same.

If you really want to get this touches, have one hack that allow this.

In your subclass of UIScrollView override the hitTest method like this:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {

  UIView *result = nil;
  for (UIView *child in self.subviews)
    if ([child pointInside:point withEvent:event])
      if ((result = [child hitTest:point withEvent:event]) != nil)
        break;

  return result;
}

This will pass to you subclass this touches, however you can't cancel the touches to UIScrollView super class.

SEQOY Development Team