允许在 UIWebView 上禁用滚动?

2023-10-22移动开发问题
7

本文介绍了允许在 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 上禁用滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

恢复游戏 cocos2d
Resume game cocos2d(恢复游戏 cocos2d)...
2024-08-12 移动开发问题
6

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

[ios.cocos2d+box2d]如何禁用自动旋转?
[ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)...
2024-08-12 移动开发问题
7

从 Documents 目录存储和读取文件 iOS 5
Storing and reading files from Documents directory iOS 5(从 Documents 目录存储和读取文件 iOS 5)...
2024-08-12 移动开发问题
9

如何在 cocos2d 环境之外实现 cocos2d 游戏的虚拟摇杆?
How can I implement a virtual joystick for a cocos2d game outside the cocos2d environment?(如何在 cocos2d 环境之外实现 cocos2d 游戏的虚拟摇杆?)...
2024-08-12 移动开发问题
13