iPad的应用程序崩溃当我打电话UIDocumentInteractionController法“presentOpenInMenuFromRect:inView:动画:”

问题描述:

这里是我的代码:在iPad上它是在iPhone崩溃列表中出现,但所选择的应用程序是没有得到开放。iPad的应用程序崩溃当我打电话UIDocumentInteractionController法“presentOpenInMenuFromRect:inView:动画:”

- (void)openIn:(NSURL *)fileFullPath { 
    docController = [UIDocumentInteractionController interactionControllerWithURL:fileFullPath]; 
    [docController setDelegate:self]; 

    BOOL isOpen = [docController presentPreviewAnimated:YES]; 

    if (isOpen == NO) { 
     BOOL isOpenIn = [docController presentOpenInMenuFromRect:CGRectMake(300, 300, 100, 100) inView:self.view animated:NO]; 

     if(isOpenIn == NO) { 
      return ; 
     } 
    } 
} 

如果仍然相关,则问题可能是UIDocumentInteractionController从内存中释放。尝试将其定义为实例变量。

按Lupos的回答,定义了我的docController实例变量固定的,你是看到了同样的问题。

我没有足够的声誉对他的回答进行评论。

// In your .h file 
@property (nonatomic, strong) UIDocumentInteractionController *docController; 

// When calling in your .m 
docController = [UIDocumentInteractionController interactionControllerWithURL:fileFullPath]; 
+0

我正在使用此代码,但Xcode给了我一个问题。出于某种原因,它迫使我指docController在.m文件为“_docController”以编译。当我这样做的时候,所有的工作都很好,只是好奇它为什么不同于你的解决方案。谢谢。 – njtman

+0

它看起来像我刚刚找到了我自己的问题的答案。看看这里http://*.com/a/14188856/1015387 – njtman