简体   繁体   English

如何使UIWebView不像iPhone上的浏览器那样工作

[英]How to make UIWebView not act like a browser on the iPhone

My app loads webpages off the internet using a UIWebView. 我的应用程序使用UIWebView从Internet上加载网页。 However I'd like to modify the experience so the user won't perceive it to be a webpage. 但是,我想修改体验,以使用户不会将其视为网页。 What are some of the things I can do? 我可以做些什么? and how to do it? 以及如何做?

examples: - Show the page when everything is loaded? 示例:-加载所有内容后显示页面? - Fade in effect? -淡入淡出效果?

Suggestions please. 请提出建议。

I assume you are wanting to display the page as if it is a resource contained within your app (and not something streaming from a browser?) 我假设您要显示页面,就像页面是应用程序中包含的资源一样(而不是浏览器中的某些内容?)

In this case, download the webpage to a local file and display it only once fully downloaded. 在这种情况下,请将网页下载到本地文件,并仅在完全下载后才显示。

I provide sample code in this answer that you can easilyy adapt for a html page (rather than a pdf document) 我在此答案中提供了示例代码,您可以轻松地适应html页面(而不是pdf文档)

It is possible to monitor the delegate callbacks from UIWebView to determine when the page has finished loading, and then perform whatever visual effect you want at that time. 可以从UIWebView监视委托回调,以确定页面何时完成加载,然后执行当时想要的任何视觉效果。 If the web view is most or all of your view controller, you could defer pushing your view controller until that time, or you could fade in the view as you mentioned. 如果Web视图是视图控制器的大部分或全部,则可以推迟将视图控制器推到那个时候,或者您可以淡入视图。

However, even when reading HTML from the local disk, there is a noticeable lag. 但是,即使从本地磁盘读取HTML,也存在明显的滞后。 Waiting for remote content to load will have even more latency. 等待远程内容加载将有更多的延迟。 You also must deal with the realities of an unreliable network: sometimes, your content will never arrive. 您还必须应对不可靠网络的现实:有时,您的内容永远不会到达。

Once the first page is loaded and displayed, though, your options will be limited. 但是,一旦加载并显示了第一页,您的选择将受到限制。 If you try to make it appear that it is a fully native application, it's going to be hard to explain the latency or why it doesn't run when the network is unavailable (airplane mode, no cell or Wi-Fi). 如果您试图使它看起来像是一个完全本机的应用程序,将很难解释延迟或为什么在网络不可用(飞机模式,无蜂窝或Wi-Fi)时无法运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM