UIDocumentInteractionController在iPad模拟器(XCode 3.2.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
委托方法不会被调用。
任何提示如何使其工作?
答
在此确认相同的行为:在模拟器上调用- (BOOL)presentPreviewAnimated:
返回NO
,但在设备上工作。感谢您指出这一点,我只花了两个小时一次又一次地检查我的代码。到目前为止没有解决方案。
答
我实际上在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