Can*_*ğlu 3 ios uidocumentinteraction ios6
我有一个UIDocumentInteractionController实例(DOES在我班上一个有力的参考,我知道关于它的内存问题),我想将照片文件发送到Instagram的.
我使用ig扩展名保存了文件(尝试igo过)并且我正在呈现控制器.Instagram显示在列表中.我点击Instagram,没有任何反应.
NSURL *imageFile = [NSURL fileURLWithPath:path];
interactionController = [UIDocumentInteractionController interactionControllerWithURL:imageFile];
interactionController.UTI = @"com.instagram.photo";
interactionController.annotation = [NSDictionary dictionaryWithObject:@"my caption" forKey:@"InstagramCaption"];
interactionController.delegate = self;
[interactionController presentOpenInMenuFromRect:self.view.frame inView:self.view animated:YES];
Run Code Online (Sandbox Code Playgroud)
为了进一步调查,我将我的调用类设置为委托并实现了willBeginSendingToApplication:和didEndSendingToApplication:方法.有趣的是,我意识到willBeginSendingToApplication:确实会被调用,但didEndSendingToApplication:事实并非如此.我已经尝试更改我的文件扩展名,将UTI更改为com.instagram.exclusivegram,检查文件URL是否正确等等,但它们似乎都不起作用.没有错误,控制台中没有任何东西.交互控制器关闭,我的应用程序保持工作,因为它以前工作,没有任何反应.我已经读过iOS 6上可能存在一些问题,但我的应用程序是iOS 6应用程序,所以我无法在iOS <6上测试它.我发现的唯一接近我的问题的是UIDocumentInteractionController,没有文件扩展但UTI,但它过多地进入低级别位,我也没有非ARC代码.
可能是问题的原因是什么?
如果文件不存在,但如果您没有正确构造文件URL,则会发生这种情况.这困扰了我一段时间.
确保构建文件URL,如下所示:
NSURL *pagesURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"MyGreatPDF.pdf" ofType:nil]];
Run Code Online (Sandbox Code Playgroud)
而不是这样的:
NSURL *pagesURL = [NSURL fileURLWithPath:@"MyGreatPDF.pdf"];
Run Code Online (Sandbox Code Playgroud)
后者仍然形成一个有效的URL,但它获得一个"私人"前缀,file:///private/var/mobile/Applications/00000000-0000-0000-0000-000000000000/MyGreatApp.app/MyGreatPDF.pdf而不是file:///var/mobile/Applications/00000000-0000-0000-0000-000000000000/MyGreatApp.app/MyGreatPDF.pdf
过了很长一段时间,我发现该文件没有正确保存,并且不存在。iOS 并没有抛出任何类型的错误,只是静静地失败。我已经更正了有关生成文件的代码,当文件存在时,控制器就出现了。也许苹果应该添加一些断言/异常机制来处理文档交互控制器中不存在的文件。
| 归档时间: |
|
| 查看次数: |
4475 次 |
| 最近记录: |