2012-04-11 69 views
1

我以前- (BOOL)presentPreviewAnimated:(BOOL)animated;加载文档,然后我想借此从doc.So我尝试的iOS UIDocumentInteractionController截图

UIGraphicsBeginImageContext(self.view.bounds.size); 
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
currentImage=UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

,但它只是把MAINVIEW截图,所以我想找人能告诉我怎么拿文档视图的图层。

回答

0

这不会工作,因为弹出窗口(有一个包含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本身。

这些结果并不是最优的,但可能足够用于非生产性的东西(我假设您希望将其显示给其他人等)。

+0

它没有工作,现在的形象只是白色 – snorlax 2012-04-11 04:33:54

+0

更新了答案,它现在的作品:) – nacho4d 2012-04-11 05:16:17

+0

它现在正常工作,:) – snorlax 2012-04-11 06:47:35