将图像从UIWebView保存到iOS中的照片库中

时间:2012-05-09 05:30:23

标签: ios cocoa-touch

我想将图像从UIWebView保存到iOS应用程序的照片库中。

我也读过[http://stackoverflow.com/questions/6766671/how-to-saving-uiwebview-content-into-photo-library] [1]

但我无法拯救。 我在保存方法中写了以下代码。

- (IBAction)saveImage:(id)sender
{
    NSString *sizeOfImageByJs = [NSString stringWithFormat:@"document.body.scrollWidth;"
                                 "document.body.scrollHeight;"
                                 "window.innerWidth;"
                                 "window.innterHeight;"];


    NSString *urlToSave = [webViewOfPhoto stringByEvaluatingJavaScriptFromString:sizeOfImageByJs];

    NSURL *imageUrl = [NSURL URLWithString:urlToSave];
    NSData *imageData = [NSData dataWithContentsOfURL:imageUrl];
    UIImage *image = [UIImage imageWithData:imageData];

    UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);
}

它不能保存任何东西。 怎么保存? 感谢。

0 个答案:

没有答案
相关问题