UIWebview size limit

試著忘記壹切 提交于 2019-12-07 21:18:57

问题


Everytime I load a html file that is larger than 2MB my app crashes. Is there a limit to how big a web page can be? How can I not crash my app (partial loading?)


回答1:


When you load 2MB of HTML, the UIWebView has to consume a lot of memory to create a DOM and all of the controls/graphics/etc. to actually show the page. The limit is not the HTML size, but the resulting amount of memory that is needed to display it. Run it in the simulator with the Activity Monitor to see memory consumption

Xcode Instruments: peak RAM of iPhone apps running in Simulator?

You'll need to break down your pages or find another way to do the markup to make the memory smaller. Note that just making the HTML smaller might not help if you need to create the same page.




回答2:


I bet you're ignoring the memory warnings that are being sent to your UIViewController subclass that is home to your UIWebView.

Uncomment -(void)didReceiveMemoryWarning and emit some NSLog messages from there. You'll probably see that the phone is frantically trying to get your attention about a low-memory condition. And when you don't respond by lowering memory use, it kills you.

What you want to do in that method is free any resources you're holding on to--images, big chunks of data, etc.



来源:https://stackoverflow.com/questions/3439728/uiwebview-size-limit

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