1

I have a some custom UIControls inside a UIScrollView subclass. The custom controls work by detecting touches to change the value of the control, obviously having touch sensitive controls inside a scroll view this can be weird (is the user trying to scroll up and down or change the value of the control?).

So I overrode the touchesShouldBegin:withEvent:inContentView and touchesShouldCancelInContentView methods. In iOS5 and iOS6 if I set touchShouldBegin to return TRUE (meaning the touch event msg is sent to the subview rather then the scroll view) ONLY the controls work and the scrollview wouldn't scroll which is great. However in iOS7 something has changed (who woulda guessed), the scrollview will scroll as if nothings ever changed but at the same time the controls also receive the msg. If i'm touching and dragging slow enough on the control it will work but if I move my finger to fast the scrollview takes over and starts to scroll.

- (BOOL) touchesShouldBegin: (NSSet *) _touches
              withEvent: (UIEvent *) _event
          inContentView: (UIView *) _view{

self.touch = _touches.anyObject;

if ([_view isKindOfClass: [MyControl class]])
{
    MyControl *control = (MyControl *)_view;
    if ([control touchWasOnTrackButton: _touches.anyObject] ||
        [control touchWasOnInnerButton: _touches.anyObject])
    {
        NSLog(@"CONTROL TOUCHED");
        return YES;
    }
    else
    {
        NSLog(@"TABLEVIEW TOUCHED");
        return NO;
    }
}
else
{
    NSLog(@"TABLEVIEW TOUCHED");
    BOOL touchesShouldBegin = [super touchesShouldBegin: _touches withEvent: _event inContentView: _view];
    return touchesShouldBegin;
}
}

Does anyone know whats changed in iOS7 and how they solved this issue. Thanks

anders
  • 4,168
  • 2
  • 23
  • 31

1 Answers1

0

So I was able to fix this issue by something rather hackish

My UIControl subclass has protocols methods for controlStartedTracking and controlStoppedTracking. In controlStatedTracking I set the myScrollViewRefernce.scrollEnabled = FALSE; and in controlStoppedTracking I reenable it myScrollViewRefernce.scrollEnabled

If anyones got anything better, let me kno

anders
  • 4,168
  • 2
  • 23
  • 31