問題描述
有誰(shuí)知道如何阻止 UIWebView 垂直彈跳?我的意思是當(dāng)用戶觸摸他們的 iPhone 屏幕,向下拖動(dòng)手指時(shí),webview 會(huì)在我加載的網(wǎng)頁(yè)上方顯示一個(gè)空白點(diǎn)?
Does anyone know how to stop a UIWebView from bouncing vertically? I mean when a user touches their iphone screen, drags their finger downwards, and the webview shows a blank spot above the web page I had loaded?
我查看了以下可能的解決方案,但沒有一個(gè)對(duì)我有用:
I've looked at the following possible solutions, but none of them worked for me:
http://www.iphonedevsdk.com/forum/iphone-sdk-development/996-turn-off-scrolling-bounces-uiwebview.html
http://forums.macrumors.com/showthread.php?t=619534
如何阻止 UIScrollView 水平彈跳?
推薦答案
for (id subview in webView.subviews)
if ([[subview class] isSubclassOfClass: [UIScrollView class]])
((UIScrollView *)subview).bounces = NO;
...似乎工作正常.
App Store 也會(huì)接受它.
It'll be accepted to App Store as well.
更新:在 iOS 5.x+ 中有一種更簡(jiǎn)單的方法 - UIWebView
具有 scrollView
屬性,因此您的代碼可以如下所示:
Update: in iOS 5.x+ there's an easier way - UIWebView
has scrollView
property, so your code can look like this:
webView.scrollView.bounces = NO;
WKWebView
也是如此.
這篇關(guān)于阻止 UIWebView “彈跳";垂直?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!