嘗試這樣:
- (void) getFullScreenScreenShot
{
AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
UIView* superView = appDelegate.viewController.view;
CGRect fullScreenFrame = superView.frame;
UIGraphicsBeginImageContextWithOptions(fullScreenFrame.size, YES, 0.0f);
CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0.0f, 0.0f);
[superView.layer renderInContext: UIGraphicsGetCurrentContext()];
UIImageView* screenShot = [[UIImageView alloc] initWithImage: UIGraphicsGetImageFromCurrentImageContext()];
UIGraphicsEndImageContext();
NSData* imageData = UIImageJPEGRepresentation(screenShot.image, 1.0);
NSString* previewFileNamePath = [[CPFileManager documentsPath] stringByAppendingString: @"image.jpg"];
if ([imageData writeToFile: previewFileNamePath
atomically: NO])
{
NSLog(@"See filename:%@", previewFileNamePath);
}
else
{
NSLog(@"Error: %@", previewFileNamePath);
}
}
什麼是'caputureView'?確保你是對的 - 調試。 – Wain
明確輸入你想要的和你在輸入和傳送帶視圖數據中使用的東西 – Mahe
@DO Sunhour:你是否嘗試給出硬編碼的屏幕大小..?嘗試捕獲窗口。 – Nilesh