iOS6中使用QLPreviewController的renderincontext问题

时间:2012-10-10 15:36:54

标签: ios

我已经在互联网上搜索了这个问题,但还没有找到答案。

我正在编写一个使用QLPrieviewController显示文档的应用程序。我想拍摄屏幕并将其复制到外部显示器。我有它为ios5工作,代码如下。此代码不再适用于ios6。

    UIGraphicsBeginImageContextWithOptions(self.previewController.view.frame.size, NO, 0.0);
    [self.previewController.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage * clonedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    [mirrorWebPageView setImage: clonedImage];

我尝试使用渲染前窗来查看我将使用以下代码获得的内容。

    NSArray * currentwindows = [[UIApplication sharedApplication] windows]; 
    UIWindow *trythisone = [currentwindows objectAtIndex:0];
    UIGraphicsBeginImageContextWithOptions(trythisone.frame.size, NO, 0.0);
    [trythisone.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage * clonedImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    [mirrorWebPageView setImage: clonedImage];

我显示了导航栏和底部工具栏,但QLPreviewController的内容未显示在视图中。

我已经读过RenderIncontext存在一些问题,但是无法确定这是否是我的问题。

关于如何解决这个问题的任何想法都会有所帮助。

由于

2 个答案:

答案 0 :(得分:0)

我尝试在iOS6上以编程方式进行屏幕捕获,它只捕获背景视图。在iOS5上它会工作。它可能是一种安全功能,可以阻止程序捕获您正在查看的内容并将其发送到某个地方。

答案 1 :(得分:0)

这是不可能的,因为在最新版本的iOS上,您的进程不再显示预览文档。预览机制由另一个进程处理。