我實際上在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非常重要,只要定期發佈,就會崩潰。
謝謝您的確認。我已經向Apple提交了一份錯誤報告。我爲他們建立了一個演示項目。 – 2010-09-17 08:55:31
注意:iOS 4.2版測試版中的問題已消失。 – 2010-09-22 11:04:32