iphone - 获取网页图片

标签 iphone ios objective-c ios5 ios4

我正在 try catch 网页的完整图像..
但它显示空白图像..

我应该怎么做才能获得完整的网页图像?

我试过了

CGSize overallSize = [WebPageImage sizeThatFits:CGSizeZero];
UIGraphicsBeginImageContext(WebPageImage.scrollView.contentSize);
WebPageImage.bounds = CGRectMake(0, 0, overallSize.width, overallSize.height);
while (WebPageImage.loading) {
    [NSThread sleepForTimeInterval:0.1];
}
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,(unsigned long)NULL), ^(void) {
    UIImageWriteToSavedPhotosAlbum(viewImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
});

请提出一些解决方案..
WebPageImage 是 UIWebView..

最佳答案

UIGraphicsBeginImageContextWithOptions(WebPageImage.bounds.size, WebPageImage.opaque, 0.0);
[WebPageImage.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

关于iphone - 获取网页图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16102853/

相关文章:

ios - XIB 的内容未加载

ios - 如何使用 SwiftUI 调整图像大小?

ios - 无法查询用户 CKRecords

Objective-C imageWithCGImage 内存泄漏

objective-c - 苹果操作系统 X : Best way to do runtime check for retina display?

objective-c - 执行选择器 ARC 警告

iphone - Iphone 的 UIPOPOVER?还是假的?

iphone - 问题推ViewController后播放MP3

iphone - FBConnect (IPHONE),自定义发布对话框

php - 在 iOS 和 Android 的 PHP 中创建 SQLite 文件