我有一个启用分页的UIScrollView,如下所示:
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];
我在UIScrollView中添加了几个UIWebView,并将它们的交互启用设置为“是”。
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
self.frame = frame;
self.userInteractionEnabled = YES;
}
return self;
}
这会破坏分页并影响UIScrollView上的所有触摸事件。如果我将用户交互设置为NO,分页可以正常工作,但我无法在UIWebView中突出显示文本。我尝试像下面这样子类化UIScrollView,但是仍然出现相同的情况。有什么想法吗?
- (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];
}