I have a UISlider
as part of a view that is loaded into a UIScrollView
with paging enabled. I\'ve noticed an unexpected behavior. If the user tries
You can subclass UIScrollView and override the method - (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view
as follows:
- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view {
if ([view isKindOfClass:[UISlider class]]) {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:view];
CGRect thumbRect;
UISlider *mySlide = (UISlider*) view;
CGRect trackRect = [mySlide trackRectForBounds:mySlide.bounds];
thumbRect = [mySlide thumbRectForBounds:mySlide.bounds trackRect:trackRect value:mySlide.value];
if (CGRectContainsPoint(thumbRect, location))
return YES;
}
return NO;
}
Also Set yourScrollView.delaysContentTouches = NO;
property for the scrollview.