loadHTMLString won't fire while UIScrollView is scrolling

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 21:53:25

问题


I'm trying to lazy load UIWebViews inside a UIScrollView. Every time the user scrolls, the WebViews frames are 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.


回答1:


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.



来源:https://stackoverflow.com/questions/4200563/loadhtmlstring-wont-fire-while-uiscrollview-is-scrolling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!