ios 6 uiwebview shows background while scrolling a

2019-07-19 17:34发布

I have a web page being displayed in a UIWebView that uses jquery scrollTop (using 1.6.4 version of jquery) to scroll the window to a speicified position after the page is loaded. This was working fine with xcode older than 4.5. After I built it using xcode 4.5 the page momentarily shows the background of the UIWebView before scrolling.

This happens only in ios6. Has anyone encountered any similar issue with xcode 4.5 and ios6? Is there any new API for UIWebview that I can use to stop this annoying behaviour?

1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-07-19 17:56

Solved this, here is the solutions in case anyone stumbles over this issue in future :

Apparently in iOS6 UIWebView when you use the jQuery ScrollTop to scroll the window or document or body of a page the UIWebview flickers showing the background of the UIWebview momentarily. The simple fix for this is that instead we should make a div scrollable(user overflow:auto) and use scrollTop on that. Now scrollTop will work and will make the div scroll to the proper position supplied by you, but surprises surprises, the scrolling in a scrollable div in UIWebview will be not smooth (read horrible) so we have to include a CSS tag (works only on ios5 and above) called -webkit-overflow-scrolling: touch; and everything magically works.

Cheers !!

查看更多
登录 后发表回答