我使用- (BOOL)presentPreviewAnimated:(BOOL)animated;
加载文档,然后我想从doc中截取屏幕截图。所以我试试
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
currentImage=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
但它只是主视图,所以我在找人可以告诉我如何获取文档视图的图层。
答案 0 :(得分:0)
这不起作用,因为popovers(包含UIDocumentInteractionController的那个)没有添加到视图控制器的视图中。
将它们添加到应用程序窗口顶部的自己的视图中。
// This is kind of hacky, do not use for production :)
// Make sure this code is executed while the popover is being shown.
UIView *uiDimmingView = [[[[UIApplication sharedApplication] keyWindow] subviews] lastObject];
UIView *uiPopoverView = [[uiDimmingView subviews] lastObject];
如果您使用uiDimmingView
,您将获得包含弹出窗口的整个视图。 uiPopoverView
本身就是popover。
这些结果不是最佳的,但对于非生产的东西来说可能已经足够了(我假设您希望将它展示给其他人等)。