w I'm trying to take a cocoa webview screenshot with this code:
NSBitmapImageRep *bitmapRepRight = [[webView mainFrame].frameView bitmapImageRepForCachingDisplayInRect:cacheRect]; [[[webView mainFrame].frameView documentView] layout]; [[webView mainFrame].frameView cacheDisplayInRect:cacheRect toBitmapImageRep:bitmapRepRight]; return [bitmapRepRight CGImage];
This code is called from the frame function - (void) webView: (WebView *) didFinishLoadForFrame: (WebFrame *).
I get only the background image of the page, but neither text nor images.
If I call it using [self performSelector: @selector (addPagesToCache) withObject: nil afterDelay: 0.01]; then it works, but itβs not a completely clean way.
What could be the problem and how can I fix it?
source share