【问题标题】:iPad application crashes when I call UIDocumentInteractionController method "presentOpenInMenuFromRect: inView: animated:"当我调用 UIDocumentInteractionController 方法“presentOpenInMenuFromRect:inView:animated:”时 iPad 应用程序崩溃
【发布时间】:2012-06-07 09:30:56
【问题描述】:

这是我的代码:在 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 ;
        }
    }
}

【问题讨论】:

    标签: iphone ios ipad


    【解决方案1】:

    根据 Lupos 的回答,为我的 docController 定义一个实例变量解决了您所看到的相同问题。

    我没有足够的声誉来评论他的回答。

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

    【讨论】:

    • 我正在使用这段代码,但是 Xcode 给了我一个问题。出于某种原因,它迫使我将 .m 文件中的 docController 称为“_docController”以进行编译。当我这样做时一切正常,只是好奇为什么它与您的解决方案不同。谢谢。
    • 看来我刚刚找到了自己问题的答案。看这里stackoverflow.com/a/14188856/1015387
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-26
      • 1970-01-01
      • 2015-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多