Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I tell when a UIWebView is done rendering (not loading)?

I know when its done loading... (webViewDidFinishLoad), but I want to use

[webView.layer renderInContext:UIGraphicsGetCurrentContext()]; 

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.

like image 893
tillerstarr Avatar asked Apr 27 '11 19:04

tillerstarr


1 Answers

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 

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.

like image 175
Sean Reilly Avatar answered Sep 19 '22 20:09

Sean Reilly