Ser*_*yov 1 cocoa-touch objective-c ibooks ios uidocumentinteraction
我有一个测试PDF文件,我想通过我的应用程序在iBooks中打开.我将它保存在我的临时目录中,并使用此代码将其加载到iBooks:
NSURL *targetURL = [NSURL fileURLWithPath:tempFullPath];
NSLog(@"Path is %@", tempFullPath);
UIDocumentInteractionController *controller = [UIDocumentInteractionController interactionControllerWithURL:targetURL];
controller.delegate = self;
controller.UTI = @"com.adobe.pdf";
[controller presentOpenInMenuFromRect:self.view.bounds inView:self.view animated:YES];
Run Code Online (Sandbox Code Playgroud)
弹出的菜单很好但是当我点击iBooks按钮时,应用程序崩溃并挂起我的Xcode.
我在NSLog输出中获得的文件路径如下:
Path is /private/var/mobile/Applications/65EC4182-A79B-431C-9E74-BD72D91A31AB/tmp/TestFile.pdf
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?提前致谢!
使用a UIDocumentInteractionController要求您保持参考,直到完成为止.这意味着您应该使用实例变量,而不是局部变量.实现适当的委托方法,以便在完成控制器后重置ivar.
启用僵尸将有助于调试此类问题.很可能您会看到正在将消息发送到解除分配的对象(您的控制器).
| 归档时间: |
|
| 查看次数: |
3422 次 |
| 最近记录: |