スクリーンキャプチャをカメラロールに取り込むためにインターネットから取得したコードが少しあります。これはうまく機能します。ここにあります。
CGRect screenRect = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.bounds.size.width, self.view.bounds.size.height);
UIGraphicsBeginImageContext(screenRect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextFillRect(ctx, screenRect);
[self.view.layer renderInContext:ctx];
UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(screenImage, nil, nil, nil);
UIGraphicsEndImageContext();
すべてがiPhoneで完璧に機能しますが、今はiPadで状況を変えています。画面全体とは異なる長方形をキャプチャする必要があるため、次のように別の長方形を指定しています。
CGRect screenRect;
switch (runningOniPad) {
case 0: // running on iPhone..
screenRect = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y, self.view.bounds.size.width, self.view.bounds.size.height);
break;
default: // yes, running on iPad..
screenRect = CGRectMake(56, 478, 662, 262);
break;
}
カメラロールで取得している長方形はSIZEimで指定されていますが、その原点は(0,0)のようです...おそらく[self.view.layer renderInContext:ctx]; ??
誰かが助けてくれるなら、きっと感謝します、どうもありがとうございました:)