Fix touch delay on controls in scroll views
All subclasses of UIScrollView will delay touch delivery to any UIControls inside.
This delay is about 1 second and creates a sensible stutter. There is a simple fix that additionally adds a feature to cancel touch on control if it turned into panning.
@implementation MYCollectionView
- (id)initWithCoder:(NSCoder *)aDecoder {
if(self = [super initWithCoder:aDecoder]) {
// Disable touch delays to avoid highlighting delay on UIControls
self.delaysContentTouches = NO;
}
return self;
}
- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
// Cancel tap on UIControls if user moved finger
return YES;
}
@end
Written by Andrej Mihajlov
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ios
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#