0

私は持っていUIWebViewます。データを UIWebView にロードした後、UIWebView水平方向にスクロールでき、Web ビューで scrollView のページングを有効にします。

私の質問は:

UIWebView の scrollView でページを画像に保存する方法はありますか? つまり、5 ページの scrollView (コンテンツ サイズ = 5 ページ) に対して 5 つの画像を取得します。

4

3 に答える 3

0

このコードは、ユーザーが現在のビューのスクリーンショットをキャプチャして、この画像を共有または保存する場合に役立ちます。

- (UIImage *)captureView {

//hide controls if needed
CGRect rect = [self.view bounds];

    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    [self.view.layer renderInContext:context];   
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return img;

}

私のブログを参照してください... http://parasjoshi3.blogspot.in/2012/06/captureimagescreenshot-of-view.html

:)

于 2012-10-08T09:30:33.223 に答える
0
CGRect rect = [webview bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
[webview.layer renderInContext:context];   
UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

これは、現在の画像をキャプチャするのに役立ちます

于 2012-10-08T09:33:02.490 に答える
0

この方法で画面を保存できます:-

 -(IBAction)savebutn:(id)sender
 {
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *saveImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();
NSData *imageData = UIImagePNGRepresentation(saveImage);
NSFileManager *fileMan = [NSFileManager defaultManager];

NSString *fileName = [NSString stringWithFormat:@"%d.png",imagename];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *pdfFileName = [documentsDirectory stringByAppendingPathComponent:fileName];
[fileMan createFileAtPath:pdfFileName contents:imageData attributes:nil];


 }

画像は、ドキュメント ディレクトリに .png 拡張子で保存されます

于 2012-10-08T09:29:04.177 に答える