简体   繁体   English

在UIWebView中加载大型网页

[英]Loading large web page in UIWebView

Whenever I load a large web page in a UIWebView in my app, it always crashes (low memory) after a few seconds before the page is fully loaded. 每当我在我的应用程序中的UIWebView中加载大型网页时,它会在页面完全加载之前几秒钟后崩溃(内存不足)。 The page is about 500k in size. 该页面大小约为500k。 the page loads fine in safari, however i noticed that the entire page is not rendered initially. 页面在safari中加载很好,但是我注意到整个页面最初没有呈现。 (showing a checkerboard background) (显示棋盘背景)

How can I do that so that UIWebView doesn't crash when loading a big file? 我怎么能这样做,以便在加载大文件时UIWebView不会崩溃?

Well One simple approach that works in Optimizing UIWebView is pretty simple and I found it effective in one of my app. 那么优化UIWebView的一个简单方法非常简单,我发现它在我的应用程序之一中有效。 Creating new instances of UIWebView each time on user's action is not a feasible solution and most likely crashes the app after a few loads. 每次在用户的操作上创建UIWebView的新实例都不是一个可行的解决方案,并且很可能在几次加载后崩溃应用程序。 Keep a Single Instance of UIWebView that you can work with throughout your app, so that you don't have to call ALLOC on UIWebView every time you want to load a web page. 保留可在整个应用程序中使用的单个UIWebView实例,这样您就不必在每次要加载网页时都在UIWebView上调用ALLOC。 Just use the UIWebView's loadRequest: method to change the URL you want to point the user to. 只需使用UIWebView的loadRequest:方法更改您希望将用户指向的URL。 I hope this reduces you memory consumption. 我希望这可以减少你的记忆消耗。

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

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