I have a UIScrollView with paging, for example:
container = [[UIScrollView alloc] initWithFrame:kScrollViewFrame]; [container setDelegate:self]; [container setShowsHorizontalScrollIndicator:YES]; [container setShowsVerticalScrollIndicator:NO]; [container setClipsToBounds:YES]; [container setPagingEnabled:YES]; [container setDecelerationRate:UIScrollViewDecelerationRateFast]; [container setBounces:NO]; [container setUserInteractionEnabled:NO]; [container setCanCancelContentTouches:NO]; [container setDelaysContentTouches:NO];
In UIScrollView, I will add some UIWebViews and set their interaction to yes like that.
- (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code self.frame = frame; self.userInteractionEnabled = YES; } return self; }
which breaks the paging and everyone touches the UIScrollView. If I set the user interaction to NO, the page works, but I cannot select the text in the UIWebView. I tried to subclass UIScrollView as follows, but the same thing happens. Any idea?
- (id)initWithFrame:(CGRect)frame { NSLog(@"init"); return [super initWithFrame:frame]; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"touchesBegan"); [[self nextResponder] touchesBegan:touches withEvent:event]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"touchesMoved"); [[self nextResponder] touchesMoved:touches withEvent:event]; } - (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"touchesEnded"); [[self nextResponder] touchesEnded:touches withEvent:event]; }
Oh danny boy
source share