2014-02-21 34 views
0

我有一個問題,以捕獲全屏iCarousel。它只能捕獲Carousel的索引。無法捕獲全屏iCarousel

UIGraphicsBeginImageContext(caputureView.bounds.size); 
    [caputureView.layer renderInContext:UIGraphicsGetCurrentContext()]; 
    UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
+0

什麼是'caputureView'?確保你是對的 - 調試。 – Wain

+0

明確輸入你想要的和你在輸入和傳送帶視圖數據中使用的東西 – Mahe

+0

@DO Sunhour:你是否嘗試給出硬編碼的屏幕大小..?嘗試捕獲窗口。 – Nilesh

回答

0

嘗試這樣:

- (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); 
    } 
} 
+0

它仍然只能得到索引iCarousel ....有沒有人有這個問題作爲我? –

+0

我編輯了我的答案。我得到了全屏截圖,沒有任何問題 – stosha