2010-09-01 90 views
3

UIDocumentInteractionController在iPad Simulator(「iPhone Simulator」4.0版,隨XCode 3.2.3一起發貨,使用iOS版本3.2)中顯示爲不起作用。UIDocumentInteractionController在iPad模擬器(XCode 3.2.3)中不工作

我有一個簡單的示例代碼,使用UIDocumentInteractionController來呈現PDF預覽。它在設備上工作。在iPad上presentPreview只是返回NO,UIDocumentInteractionController's委託方法不會被調用。

任何提示如何使其工作?

回答

3

在此確認相同的行爲:在模擬器上調用- (BOOL)presentPreviewAnimated:返回NO,但在設備上工作。感謝您指出這一點,我只花了兩個小時一次又一次地檢查我的代碼。到目前爲止沒有解決方案。

+0

謝謝您的確認。我已經向Apple提交了一份錯誤報告。我爲他們建立了一個演示項目。 – 2010-09-17 08:55:31

+0

注意:iOS 4.2版測試版中的問題已消失。 – 2010-09-22 11:04:32

0

我實際上在iOS 4.2以上的版本上有這個問題,即使這是當天已知的一個bug。

問題是UIDocumentInteractionController在設備上可以正常工作,但在模擬器中會崩潰。我發現,當我以不同的方式處理內存時,問題就消失了。所不同的是,DidEndPreview委託方法中的autoreleasing。這裏是我的代碼的核心:

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

以前我曾簡單地處理文檔創建控制器像一個普通模式的看法,併發布了它後,我提出它。

注意:autorelease非常重要,只要定期發佈,就會崩潰。

相關問題