0

我已经成功地拍摄了我在本地存储的 htmls 数组的快照。问题是,如果 html 很小,只有一串文本,那么这个过程很可能webViewDidFinishLoad会太快,并且会加载下一个 html 而不会对其进行快照。在继续下一个 html 之前,如何确保每个 html 都被快照?

[_tempWebView loadHTMLString:msg baseURL:nil]; //starting the process of the `webViewDidFinishLoad` loop

...

    - (void)webViewDidFinishLoad:(UIWebView *)webView 
{
        [self captureScreen:webView];
}

-(void)captureScreen:(UIView*) viewToCapture
{
    UIGraphicsBeginImageContext(viewToCapture.bounds.size);
    [viewToCapture.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    [_snapshot addObject:viewImage];
}
4

0 回答 0