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中,我添加了几个UIWebVIEws,并将其启用的交互设置为是这样的.
- (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];}解决方法 禁用容器上的用户交互也会在子视图上有效地禁用它.您应该启用它,使触摸事件沿视图层次结构向下传播;
[container setUserInteractionEnabled:YES];
如果要在UIWebVIEw上禁用滚动,只需进入其UIScrollVIEw
yourWebVIEw.scrollVIEw.scrollEnabled = NO;
我在我的设备上测试了这个,我可以“浏览”UIScrollVIEw并在UIWebVIEw上选择文本.
编辑:
我有这个工作!您还必须允许触摸取消:
[container setCanCancelContenttouches:YES];总结
以上是内存溢出为你收集整理的ios – UIScrollView内容不允许用户交互全部内容,希望文章能够帮你解决ios – UIScrollView内容不允许用户交互所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)