当我调用UIDocumentInteractionController方法“presentOpenInMenuFromRect:inView:animated:”时,iPad应用程序崩溃

这里是我的代码:在iPad中,iPhone正在崩溃,列表正在出现,但所选的应用程序没有打开。

- (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 ; } } } 

根据Lupos的回答,为我的docController定义一个实例variables解决了你所看到的同样的问题。

我没有足够的声望评论他的答案。

 // In your .h file @property (nonatomic, strong) UIDocumentInteractionController *docController; // When calling in your .m docController = [UIDocumentInteractionController interactionControllerWithURL:fileFullPath]; 

如果它仍然是相关的问题可能是UIDocumentInteractionController从内存释放。 尝试将其定义为一个实例variables。