Create a UIImage by rendering UIWebView on a background thread - iPhone

前端 未结 2 2010
忘掉有多难
忘掉有多难 2020-12-15 10:50

Does someone know of a way, or has a creative idea as to how to obtain an UIImage that is rendered from a UIWebView? The catch is, that is must be on a background thread.

2条回答
  •  没有蜡笔的小新
    2020-12-15 11:24

    I've been working on this, too.

    In a thread I create a view hierarchy, loop until the web-view has finished loading content.

    The webview I create is inside of a UIViewController's viewdidload-- I've tried doing

    if ([NSThread isMainThread] == NO) {[self performselectorOnMainThread: @selector(viewDidLoad)return;)}
    

    And I've done the same for dealloc'ing the webView.

    But that didn't work.. I've only found that we avoid UIWebView exceptions UNTIL we hit the autorelease pool...

    I'm using instruments to figure out why.

    Here's my attack strategy... I'm going to perform the render operation on the main thread with an off-screen view, having a separate thread running some sort of queue to manage them. I'm worried about UI lag, so it'll have to be fairly efficient.

提交回复
热议问题