开发者

loadHTMLString won't fire while UIScrollView is scrolling

I'm trying to lazy load UIWebViews inside a UIScrollView. Every time the user scrolls, the WebViews frames ar开发者_如何学Ce updated and new content SHOULD be loaded. And that's exactly where I'm having trouble. The repositioning works well, but the new content (local NSStrings, which are called using loadHTMLString) does not appear until I stop scrolling the ScrollView.

I've read this thread already: NSURLRequest won't fire while UIScrollView is scrolling.

Getting some inspiration from that, is there any association I could make between loadHTMLString and NSURLConnection? I know next to nothing about NSURLConnection.

If that's not possible, is there any other solution? Either halting the scroll for a while (like MobileRSS – an App Store app – does) or alternate loading methods?

Edit: My UIScrollView has paging enabled. So if I were to halt the scroll for a while, it should happen at every page. But I still don't know how to accomplish that.


Old question, but here is an answer for it.

You'll have to subclass the UIWebView and switch the run loops started at a overridden loadHTMLString:baseURL: and switching it back after the html has been loaded (or failed to load).

Check out this project on github which gives you an example of where to override in all the right places.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜