2012-10-25 3 views
2

Apple 기술 노트 사이트에서 화면 캡처 코드를 게시했습니다. 모든 기능은 iOS 6에서 QLPreviewController를 사용하여 미리보기중인 파일을 캡처하지 않는다는 것을 제외하고는 작동합니다.iOS 6에서 문제를 일으키는 QLPreviewController 캡처 화면

파일 미리보기를 렌더링하기 위해 일부 새로운 OpenGL ES를 사용하고 있는지 궁금합니다. 이론적으로이 코드 조각은 화면에서 무엇이든 캡처 할 수 있어야합니다. ??

http://developer.apple.com/library/ios/#qa/qa1703/_index.html

- (UIImage*)screenshot 
{ 
// Create a graphics context with the target size 
// On iOS 4 and later, use UIGraphicsBeginImageContextWithOptions to take the scale into consideration 
// On iOS prior to 4, fall back to use UIGraphicsBeginImageContext 
CGSize imageSize = [[UIScreen mainScreen] bounds].size; 
if (NULL != UIGraphicsBeginImageContextWithOptions) 
    UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0); 
else 
    UIGraphicsBeginImageContext(imageSize); 

CGContextRef context = UIGraphicsGetCurrentContext(); 

// Iterate over every window from back to front 
for (UIWindow *window in [[UIApplication sharedApplication] windows]) 
{ 
    if (![window respondsToSelector:@selector(screen)] || [window screen] == [UIScreen mainScreen]) 
    { 
     // -renderInContext: renders in the coordinate space of the layer, 
     // so we must first apply the layer's geometry to the graphics context 
     CGContextSaveGState(context); 
     // Center the context around the window's anchor point 
     CGContextTranslateCTM(context, [window center].x, [window center].y); 
     // Apply the window's transform about the anchor point 
     CGContextConcatCTM(context, [window transform]); 
     // Offset by the portion of the bounds left of and above the anchor point 
     CGContextTranslateCTM(context, 
           -[window bounds].size.width * [[window layer] anchorPoint].x, 
           -[window bounds].size.height * [[window layer] anchorPoint].y); 

     // Render the layer hierarchy to the current context 
     [[window layer] renderInContext:context]; 

     // Restore the context 
     CGContextRestoreGState(context); 
    } 
} 

// Retrieve the screenshot image 
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 

UIGraphicsEndImageContext(); 

return image; 
} 
+2

, 내가 탐색 모음이 아니라 문서의 내용을 캡처 할 수있는 정말 윈도우의 일부 적이 없다. 미리 보았던 문서를 캡처하지 못하게하는 새로운 보안 기능에 대해 어딘가에서 읽은 것 같습니다. 그러나 나는 이것을지지하는 문서를 찾을 수 없었다. – user523234

답변

0

에서이 비슷한 소리 만 나던이 나던 작업을하는 것과 같은 이유로이 실제로 나던 작업 : IOS 6 이후 iOS 6 UIGestures (Tap) stops working with QLPreviewController


가 QLPreviewController 실제로 완전히 별도의 응용 프로그램입니다 (별도의 프로세스 및 모든 것)

=> 그래서 밀어 넣으면 전체 앱이 bg로 이동합니다. 창문을 내리고있다.

=> QlController는

내가 테스트