简体   繁体   English

iOS - QuickLook - 如何在没有UIScrollView的情况下在QuickLook中打开对象

[英]iOS - QuickLook - How to open an object in QuickLook without a UIScrollView

Could anyone point me towards a resource which uses QuickLook to open a (preferably but not necessarily a pdf) file without using a UITableView? 任何人都可以指向我使用QuickLook打开(最好但不一定是pdf)文件而不使用UITableView的资源吗?

I do have this example of using QuickLook but it uses a listview which I need to get away from. 我确实有使用QuickLook的这个例子,但它使用了我需要远离的列表视图。

http://robsprogramknowledge.blogspot.com/2011/02/quick-look-for-ios_21.html http://robsprogramknowledge.blogspot.com/2011/02/quick-look-for-ios_21.html

I'm not sure how you plan to design your UI to open a file. 我不确定您打算如何设计UI以打开文件。 I've used a few different ways, so I'll toss out some ideas. 我用了几种不同的方法,所以我会抛出一些想法。 A UITableView is ideal for large amounts of files. UITableView是大量文件的理想选择。 A generic scroll view can also be used for a large number of files. 通用滚动视图也可用于大量文件。 I've used an alert view for an app that only generates one or two files. 我已经为仅生成一个或两个文件的应用程序使用了警报视图。 You could also use a view with document icons like the iPad Mail app. 您还可以使用带有iPad Mail应用程序等文档图标的视图。 To get the document icons, use UIDocumentInteractionController . 要获取文档图标,请使用UIDocumentInteractionController The WWDC 2010 DocInteraction sample code goes in great depth with how to use UIDocumentInteractionController . WWDC 2010 DocInteraction示例代码深入介绍了如何使用UIDocumentInteractionController

As for opening the file, the Quick Look framework makes that easy. 至于打开文件,Quick Look框架可以轻松实现。 A simple, self-contained solution is to subclass QLPreviewController . 一个简单的,独立的解决方案是子类QLPreviewController Then, your subclass needs to conform to the QLPreviewControllerDataSource protocol and optionally the QLPreviewControllerDelegate protocol. 然后,您的子类需要符合QLPreviewControllerDataSource协议和可选的QLPreviewControllerDelegate协议。 Next, pass it an array of NSURLs pointing to your files. 接下来,传递一个指向您的文件的NSURL数组。 You can do this either through an initializer like -initWithFiles:(NSArray *)files or through a setter. 您可以通过初始化程序(如-initWithFiles:(NSArray *)files或通过setter执行此操作。 From here, -previewController:previewItemAtIndex: just needs to index into the array to get the appropriate file to show. 从这里开始, -previewController:previewItemAtIndex:只需索引到数组中即可获得要显示的相应文件。 -numberOfPreviewItemsInPreviewController: just needs to return the size of the array. -numberOfPreviewItemsInPreviewController:只需要返回数组的大小。 Once you have this class finished, you can use any UI design you like to push this view or present it modally. 完成此课程后,您可以使用任何您喜欢的UI设计来推送此视图或以模态方式呈现它。

Hopefully this is more clear than my tutorial you've been reading. 希望这比我读过的教程更清楚。

EDIT: 编辑:

I have posted some code to Github that may help you. 我已经向Github发布了一些可能对你有帮助的代码。 I have created a file previewer class as described above. 我已经创建了一个文件预览器类 ,如上所述。 I also posted a demo app that directly uses a QLPreviewController . 我还发布了一个直接使用QLPreviewController演示应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM