正在加载...请等待 UIWebView - iPhone

发布于 2024-09-04 00:40:06 字数 395 浏览 3 评论 0原文

在 Safari 和其他浏览器中,有一个栏会指示加载进度的百分比,我自己尝试在 iPhone 上实现类似的东西,当在 UIWebView 中加载某些内容时,我希望应用程序指示加载进度的百分比正在加载的页面。

我尝试了一些谷歌搜索,意识到我们可以使用 NSURLConnection 只读取标题并获取内容长度(但不知道如何,我阅读了苹果的 NSURLConnection 文档,但可能我错过了一些东西......)。 UIWebView 加载的大小( kb ),似乎 UIWebView 不支持它的公共 API...我希望这会以我想象的其他方式完成,所以如果你有任何想法,请扔掉它出来了,感谢您的耐心阅读。

PS:我可以通过 UIWebView 的长加载进度操作向用户显示活动指示器,但我只想进一步使用加载百分比栏:)。

问候。

In Safari and other browsers, there is a bar that would indicate the percentage of the loading progress, and I, myself, trying to implement something similiar on iPhone, when loading some content in UIWebView, I would like the app to indicate the percentage of the page being loaded.

I tried some google search and realize we could use NSURLConnection to read only the header and get the Content-Length ( but don't know how to, I read the Apple's NSURLConnection docs but probably I missed something ... ). And the size ( kb ) which UIWebView had loaded, seem like UIWebView don't support it for the public API... I hope this would be complete in some other ways than I thought, so if you have any ideas, please throw it out, thanks for your patient reading.

P.S : I could just show an Activities Indicator for users with the long loading progress actions of the UIWebView but I just want to go further with the loading percentage bar :).

Regards.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无人问我粥可暖 2024-09-11 00:40:06

如果您使用 UIWebView,则无法从中获得太多细粒度的信息。如果您查看 UIWebViewDelegate 协议参考,您将获得的唯一真正的回调是 (1) 询问是否应该加载页面,(2) 当它开始加载页面时,(3) 当它完成加载时页面成功,(4)出现错误时。

换句话说,没有委托方法指示加载的增量进度。

If you're using UIWebView, there's not much fine-grained information you can get from it. If you look at the UIWebViewDelegate Protocol Reference, the only real callbacks you'll get are (1) asking if it should load the page, (2) when it starts loading the page, (3) when it finishes loading the page successfully, (4) when there was an error.

In other words, there is no delegate method indicating the incremental progress of the load.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文