Disable Scroll on a UIWebView allowed?(允许在 UIWebView 上禁用滚动?)
问题描述
我必须在文章下方显示带有 UITableView 的网络文章.
I have to show a web article with a UITableView under the article.
我发现的唯一选择是在 tableView 标题中的 UIWebView 中显示文章.
The only option I found was to display the article in a UIWebView in the tableView header.
为此,我必须获取 webView 内容的高度,并且必须禁用 webView 的滚动.
In order to do that I have to get the height of the webView content and I have to disable scrolling for the webView.
我找到了两种禁用滚动的解决方案:
I found two solutions to disable scrolling:
for (id subview in webView.subviews)
if ([[subview class] isSubclassOfClass: [UIScrollView class]])
((UIScrollView *)subview).scrollEnabled=NO;
或在 JavaScript 中:
or in JavaScript:
<script type="text/javascript">
touchMove = function(event) {
event.preventDefault();
}
我听说第一个解决方案被 Apple 禁止,但我没有任何证据.使用此解决方案会拒绝我的申请吗?如果是这样,我可以使用第二种解决方案而不会被拒绝吗?
I heard that the first solution is forbidden by Apple but I don't have any proof of it. Will my application be rejected by using this solution? If so, can I use the second solution without being rejected?
推荐答案
从 iOS5 开始我们可以直接访问 UIWebView 的滚动视图.
您可以像这样禁用滚动和反弹:
Starting with iOS5 we have direct access to the scrollview of the UIWebView.
You can disable scrolling and bounces like this:
webView.scrollView.scrollEnabled = NO;
webView.scrollView.bounces = NO;
这篇关于允许在 UIWebView 上禁用滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:允许在 UIWebView 上禁用滚动?
基础教程推荐
- 如何将图像从一项活动发送到另一项活动? 2022-01-01
- iOS - UINavigationController 添加多个正确的项目? 2022-01-01
- 如何比较两个 NSDate:哪个是最近的? 2022-01-01
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
- UIImage 在开始时不适合 UIScrollView 2022-01-01
- Play 商店的设备兼容性问题 2022-01-01
- Android Volley - 如何动画图像加载? 2022-01-01
- navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
- 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
- SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
