How do I tell when a UIWebView is done rendering (not loading)?(如何判断 UIWebView 何时完成渲染(未加载)?)
问题描述
我知道它何时完成加载...(webViewDidFinishLoad),但我想使用
I know when its done loading... (webViewDidFinishLoad), but I want to use
[webView.layer renderInContext:UIGraphicsGetCurrentContext()];
从 UIWebView 创建图像.有时我会在 webView 完成渲染之前得到图像.我可以使用 performSelector 来延迟图像的获取,但是等待的时间是任意且脆弱的.
to create an image from the UIWebView. Occasionally I get the image prior to the webView finishing its rendering. I can use performSelector to delay the get of the image, but the amount of wait is arbitrary and brittle.
推荐答案
这可能取决于您需要将视图渲染到的图形上下文类型,但您可以调用
This may depend upon the kind of graphics context you need the view rendered into, but you can call
- (void)drawRect:(CGRect)area forViewPrintFormatter:(UIViewPrintFormatter *)formatter
这显然会欺骗 UIWebView 认为它正在被打印.如果您的最终目标是捕获完整页面,这可能会有所帮助.我们最近遇到了一个问题,即使页面已完全加载,调用普通的旧 -drawRect: 如果其中一些不在屏幕上,也不会呈现整个页面.
which apparently tricks the UIWebView into thinking that it's being printed. This may help if your ultimate goal is to capture the complete page. We've had the problem recently in which even if the page was fully loaded, calling plain old -drawRect: didn't render the entire page if some of it was offscreen.
这篇关于如何判断 UIWebView 何时完成渲染(未加载)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何判断 UIWebView 何时完成渲染(未加载)?
基础教程推荐
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iOS4 创建后台定时器 2022-01-01
