【发布时间】:2014-07-23 10:09:33
【问题描述】:
我花了很多时间在谷歌搜索,但我没有得到好的结果。 我将 UIWebView 转换为 PDF,这是一个长 contentsize 的 webview(webview 中滚动的 ContentSize)。
我使用 RenderInContext 进行循环,但是当我使用 webview 转换时它会崩溃很长时间 请帮我用 20 页修复这个错误。
这是我的代码:
UIGraphicsBeginPDFContextToFile(documentDirectoryFilename, CGRectMake(0, 0, aWebView.scrollView.contentSize.width, screenHight), nil);
aWebView.scrollView.contentSize.width, screenHight), nil);
for (int i = 0; i < 20; i++) {
@autoreleasepool {
UIGraphicsBeginPDFPage();
CGContextRef currentContext = UIGraphicsGetCurrentContext();
[[[aWebView subviews] lastObject] setContentOffset:CGPointMake(0, screenHight * i) animated:NO];
[aWebView.layer renderInContext:currentContext];
currentContext = nil;
}
}
UIGraphicsEndPDFContext();
aWebView.layer.contents = nil;
我使用了 autoReleasePool 并将结果保存到文件中。但它也会产生崩溃。
【问题讨论】:
标签: ios objective-c webview uiwebview