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