【问题标题】:UIDocumentInteractionController not working in iPad Simulator (XCode 3.2.3)UIDocumentInteractionController 在 iPad 模拟器中不起作用(XCode 3.2.3)
【发布时间】:2011-04-06 17:30:11
【问题描述】:

UIDocumentInteractionController 在 iPad 模拟器(“iPhone 模拟器”4.0 版,XCode 3.2.3 附带,使用 iOS 3.2 版)中似乎不起作用。

我有一个使用UIDocumentInteractionController 呈现PDF 预览的简单示例代码。它适用于设备。在 iPad 上,presentPreview 只返回 NO,UIDocumentInteractionController's 委托方法不会被调用。

任何提示如何使它工作?

【问题讨论】:

    标签: ios ipad ios-simulator uidocumentinteraction


    【解决方案1】:

    我实际上在高于 iOS 4.2 的 iOS 版本上遇到了这个问题,尽管这在当时是一个已知的错误。

    问题是UIDocumentInteractionController 在设备上运行良好,但在模拟器中会崩溃。我发现当我对内存的管理略有不同时,问题就消失了。不同之处在于,autoreleasingDidEndPreview 委托方法中。这是我的代码的核心:

    -(void)createPDF
    {
        UIDocumentInteractionController *dc;
        //....other code to generate pdf document
        dc = [[UIDocumentInteractionController interactionControllerWithURL:loadURL] retain];
        dc.delegate = self;
    
        [dc retain];
    
        [dc presentPreviewAnimated:YES];
    }
    
    //Delegate Methods
    - (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller
    {
        [controller autorelease];
    }
    

    之前我只是简单地创建了文档控制器,就像一个常规的模态视图,并在我展示它之后释放它。

    注意:自动释放很重要,只要定期调用释放,您就会崩溃。

    【讨论】:

      【解决方案2】:

      在这里确认相同的行为:调用- (BOOL)presentPreviewAnimated: 在模拟器上返回NO,但在设备上有效。感谢您指出这一点,我只花了两个小时一次又一次地检查我的代码。目前还没有解决办法。

      【讨论】:

      • 感谢您的确认。我已经向 Apple 提交了错误报告。我已经为他们建立了一个演示项目。
      • 注意:iOS 4.2 beta 中问题已解决。
      猜你喜欢
      • 1970-01-01
      • 2012-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-26
      • 1970-01-01
      • 2011-08-03
      • 2016-06-17
      相关资源
      最近更新 更多