iOS UIScrollView setScrollEnabled 失败
在 iOS5 中,这工作正常:
[descriptionWebView.scrollView setScrollEnabled:NO];
但在任何低于 5 的 iOS 中,它都会失败:
[UIWebView scrollView]: unrecognized selector sent to instance 0x791f9e0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIWebView scrollView]: unrecognized selector sent to instance 0x791f9e0'
In iOS5 this works fine:
[descriptionWebView.scrollView setScrollEnabled:NO];
But in any iOS under 5 it fails with:
[UIWebView scrollView]: unrecognized selector sent to instance 0x791f9e0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIWebView scrollView]: unrecognized selector sent to instance 0x791f9e0'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题不在于
setScrollEnabled:
调用。实际上,UIWebView
的scrollView
直到 iOS 5 才公开(这就是它在其他方面失败的原因)。请参阅UIWebView
文档以获取更多信息。在以前版本的 iOS 中,您必须 诉诸子视图的迭代 的
UIWebView
来查找UIScrollView
。The issue isn't the
setScrollEnabled:
call. It's actually that thescrollView
of theUIWebView
wasn't exposed until iOS 5 (which is why it fails on anything else). See theUIWebView
documentation for further information.In previous versions of iOS, you had to resort to iterating through the subviews of your
UIWebView
to find aUIScrollView
.你可以做这种测试,不需要你检查它是哪个iOS版本。
You can do this kind of test which doesn't require you to check which iOS version it is.