【发布时间】:2012-04-16 05:24:15
【问题描述】:
我有一个启用分页的 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,并将它们的交互设置为 yes,就像这样。
- (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];
}
【问题讨论】:
-
你想要实现什么,你需要滚动视图滚动、网页视图滚动、分页、选择吗?请更具体。
-
我需要滚动视图到页面并且用户能够在 webvies 上选择文本(它们是滚动视图的子视图)Webview 不需要滚动,只需能够选择其文本.
-
我已经编辑了我的答案以反映您的要求,它似乎对我有用。
-
注意:文档告诉你不要把 UIWebViews 放在 UIScrollViews 中。
标签: ios uiwebview uiscrollview