在UIDocumentInteractionControlleriPad 模拟器中似乎没有功能(“iPhone 模拟器”4.0 版,随 XCode 3.2.3 一起提供,使用 iOS 3.2 版)。
我有一个简单的示例代码,使用 UIDocumentInteractionController. 它适用于设备。在 iPadpresentPreview上只返回 NO,UIDocumentInteractionController's不调用委托方法。
任何提示如何使它工作?
在UIDocumentInteractionControlleriPad 模拟器中似乎没有功能(“iPhone 模拟器”4.0 版,随 XCode 3.2.3 一起提供,使用 iOS 3.2 版)。
我有一个简单的示例代码,使用 UIDocumentInteractionController. 它适用于设备。在 iPadpresentPreview上只返回 NO,UIDocumentInteractionController's不调用委托方法。
任何提示如何使它工作?
在这里确认相同的行为:调用在模拟器上- (BOOL)presentPreviewAnimated:返回NO但在设备上工作。感谢您指出这一点,我只花了两个小时一次又一次地检查我的代码。至今没有解决办法。
实际上,我在高于 iOS 4.2 的 iOS 版本上遇到了这个问题,尽管这在当时是一个已知的错误。
问题是它UIDocumentInteractionController在设备上运行良好,但在模拟器中它会崩溃。我发现当我对内存的管理略有不同时,问题就消失了。不同之处在于autoreleasing委托DidEndPreview方法。这是我的代码的核心:
-(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];
}
以前,我只是像常规模式视图一样创建了文档控制器,并在呈现后将其释放。
注意:自动释放很重要,你会因为常规的释放调用而崩溃。