在UIScrollView滚动时,不会触发loadHTMLString [英] loadHTMLString won't fire while UIScrollView is scrolling

查看:123
本文介绍了在UIScrollView滚动时,不会触发loadHTMLString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 UIScrollView 中延迟加载 UIWebViews
每次用户滚动时,WebViews框架都会更新,并且应该加载新内容。这正是我遇到麻烦的地方。重新定位效果很好,但新内容(本地 NSStrings ,使用 loadHTMLString 调用)直到我才出现停止滚动ScrollView。

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.

我已经读过这个帖子了:当UIScrollView滚动时,NSURLRequest不会触发。

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

从中获得灵感,是否有任何关联我可以在 loadHTMLString NSURLConnection 之间进行?我对 NSURLConnection 几乎一无所知。

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

如果那是不可能的,还有其他解决办法吗?是暂停滚动一段时间(如MobileRSS - App Store应用程序 - 还是其他加载方法?)

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?

编辑:我的UIScrollView启用了分页。因此,如果我暂停滚动一段时间,它应该发生在每一页。但我仍然不知道如何做到这一点。

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.

您必须继承UIWebView并切换在重写的loadHTMLString:baseURL:
时启动的运行循环,并在加载html(或加载失败)后将其切换回来。

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).

github 上查看此项目,其中给出了一个示例覆盖所有正确的地方。

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

这篇关于在UIScrollView滚动时,不会触发loadHTMLString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆