iOS 6.0 Quicklook QLPreviewController错误:“无法找到已加载代理的预览项目” [英] iOS 6.0 Quicklook QLPreviewController errors with: "Cannot find preview item for loaded proxy"

查看:246
本文介绍了iOS 6.0 Quicklook QLPreviewController错误:“无法找到已加载代理的预览项目”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序一直在使用QLPreviewController来显示所有类型的文件,在iOS 5.x中,它似乎很好。

My application has been using the QLPreviewController to display files of all types and in iOS 5.x , it seemed to do so just fine.

现在,在iOS 6.0中,我收到一个错误,它显示了控制器但是有一个恒定的加载指示器而且实际上从未加载任何东西。

Now, in iOS 6.0, I get an error and it shows the controller but with a constant loading indicator and never actually loads anything.

日志中的错误是:无法找到已加载代理的预览项:< QLPreviewItemProxy:0x8dbf480> - 文件://localhost/Users/me/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/E6A58F8D-71F3-4C7A-B16E-4BA017E318E5/Documents/temp//Welcome.docx

其他人在iOS 6.0中遇到此问题或其他问题吗?或者有什么尝试的建议?我已经通过iPhone和iPad尝试了它,同时推动控制器并显示它。

Anyone else have this or other issues with the Quicklook in iOS 6.0? Or any suggestions of what to try? I've tried it via iPhone and iPad with both pushing the controller and presenting it.

编辑:还注意到有问题的网址(他们说的那个是坏的) )不仅以file://开头,而且以file:// localhost开头,而原始文件只是以实际路径开始(即:file:/// Users)。

Also just noticed that the URL in question (the one they say is bad) starts with not just file:// but file://localhost whereas the original file just started with an actual path (ie: file:///Users).

推荐答案

经过一系列研究并从头开始重新创建一个基本的QuickLook查看器,我发现错误仍然记录在那,但实际上显示的是文档它们不是来自我原来的项目。

Well after a bunch of research and re-creating from the ground-up a basic QuickLook viewer, I found that the error was still logged even from that BUT the documents were actually being displayed which they weren't from my original project.

然后我尝试将QLPreviewController放在NavigationController中,然后再提出它并最终遇到同样的问题。我在呈现它之前将QLPreviewController包装在UINavigationController中,因为这似乎是为navigationItem分配自定义按钮的方法。这在iOS 5.1中运行良好(如上所述),但显然iOS 6.0不喜欢这样。

I then tried putting the QLPreviewController inside a NavigationController before presenting it and ended up with the same issue. I was wrapping the QLPreviewController in a UINavigationController before presenting it because that seemed to be the way to assign the navigationItem a custom button. That worked fine in iOS 5.1 (as stated above) but apparently iOS 6.0 does not like this.

在UINavigationController中删除包含QLPreviewController的额外代码似乎允许要显示的文件。

Removing the extra code that wrapped the QLPreviewController in a UINavigationController seemed to allow the document to display.

被包裹的控制器示例:

QLPreviewController* previewer = [[QLPreviewController alloc] init];
previewer.dataSource = self;
previewer.delegate = self;
[previewer setCurrentPreviewItemIndex:0];

UINavigationController* previewNavCtrl = [[UINavigationController alloc] init];
[previewNavCtrl pushViewController:previewer animated:NO];

[self presentModalViewController:previewNavCtrl animated:YES];

更改为:

QLPreviewController* previewer = [[QLPreviewController alloc] init];
previewer.dataSource = self;
previewer.delegate = self;
[previewer setCurrentPreviewItemIndex:0];

[self presentModalViewController:previewer animated:YES];

注意:代理错误似乎仍然显示在日志中但是

Note: again the Proxy error still seems to show up in the log however

另外:如果没有NavigationController = /

ALSO: Any UIBarButtonItem customizations seem to no longer work without the NavigationController =/

更新,任何UIBarButtonItem自定义似乎都不再有用了UPDATE:我发现使用fileURLWithpath来为previewItemAtIndex生成fileURL使原始错误消失。但是,仍然会在文档无法加载的情况下出现同样的问题。

一个新错误(我见过其他人也有错误)是:

A new error (one I've seen other people having as well) is:


无法为路径发出文件扩展名:
/ Users / me / Library / Application%20Support / iPhone%20Simulator / 6.0 / Applications / 339DDF48-AF93-41B5-B81E-A39440A131C6 / Documents / temp / Welcome1.docx

Couldn't issue file extension for path: /Users/me/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/339DDF48-AF93-41B5-B81E-A39440A131C6/Documents/temp/Welcome1.docx

最终更新:好的扩展问题/错误是因为我试图在 [NSURL]时手动将%20添加到空格(使用 [NSString stringByAddingPercentEscapesUsingEncoding] 等) fileURLWithPath] 必须已经处理过。一旦我删除它,这工作,我现在在iOS 6 yay!
所以真正的问题与UINavigationController无关,但实际上是通过previewItemAtIndex传递的文件URL。

FINAL UPDATE: Ok the extension issue/error was because I was trying to manually add %20 to the spaces (using [NSString stringByAddingPercentEscapesUsingEncoding] etc) when the [NSURL fileURLWithPath] must handle that already. Once I removed that, this worked and I am now on iOS 6 yay! So the real problem was nothing to do with the UINavigationController but actually the file URL being passed via previewItemAtIndex.

这篇关于iOS 6.0 Quicklook QLPreviewController错误:“无法找到已加载代理的预览项目”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆