QLPreviewController

1 QLPreviewController

  1. Configuring a Quick Look Preview Controller
  2. Managing Item Previews

2 QLPreviewControllerDataSource

  1. Providing Data to a Quick Look Preview Controller

3 QLPreviewControllerDelegate

  1. Responding to Preview Requests
  2. Responding to User Actions

1 QLPreviewController

QLPreviewController是预览文件的UIViewController。其支持的文件类型有:

  1. iWork documents
  2. Microsoft Office documents (Office ‘97 and newer)
  3. Rich Text Format (RTF) documents
  4. PDF files
  5. Images
  6. Text files whose uniform type identifier (UTI) conforms to the public.text type (see Uniform Type Identifiers Reference)
  7. Comma-separated value (csv) files

1.1 Configuring a Quick Look Preview Controller

/// QLPreviewControllerDataSource代理
weak public var dataSource: QLPreviewControllerDataSource?
/// QLPreviewControllerDelegate代理
weak public var delegate: QLPreviewControllerDelegate?

1.2 Managing Item Previews

/// 文件能否显示
public class func canPreviewItem(item: QLPreviewItem) -> Bool

/// 刷新数据
public func reloadData()

/// 更新当前预览的类
public func refreshCurrentPreviewItem()

/// 当前显示文件所属位置
public var currentPreviewItemIndex: Int

/// 显示的所有文件
public var currentPreviewItem: QLPreviewItem? { get }

2 QLPreviewControllerDataSource

QLPreviewControllerDataSource用于显示文件。

2.1 Providing Data to a Quick Look Preview Controller

/// 可显示的Item数量
@available(iOS 4.0, *)
public func numberOfPreviewItemsInPreviewController(controller: QLPreviewController) -> Int

/// 获取要显示的文件QLPreviewItem
@available(iOS 4.0, *)
public func previewController(controller: QLPreviewController, previewItemAtIndex index: Int) -> QLPreviewItem

3 QLPreviewControllerDelegate

QLPreviewControllerDelegate用于操作文件。

3.1 Responding to Preview Requests

/// QLPreviewController将要关闭
@available(iOS 4.0, *)
optional public func previewControllerWillDismiss(controller: QLPreviewController)

/// QLPreviewController关闭
@available(iOS 4.0, *)
optional public func previewControllerDidDismiss(controller: QLPreviewController)

/// 放大效果
@available(iOS 4.0, *)
optional public func previewController(controller: QLPreviewController, frameForPreviewItem item: QLPreviewItem, inSourceView view: AutoreleasingUnsafeMutablePointer<UIView?>) -> CGRect

/// 过渡动画展示的图片
@available(iOS 4.0, *)
optional public func previewController(controller: QLPreviewController, transitionImageForPreviewItem item: QLPreviewItem, contentRect: UnsafeMutablePointer<CGRect>) -> UIImage

3.2 Responding to User Actions

/// 能否打开URL
@available(iOS 4.0, *)
optional public func previewController(controller: QLPreviewController, shouldOpenURL url: NSURL, forPreviewItem item: QLPreviewItem) -> Bool

 


Appendix

Sample Code

Swift

Quick Look Framework Reference for iOS

QLPreviewController Class Reference

QLPreviewControllerDelegate Protocol Reference

QLPreviewControllerDataSource Protocol Reference

Revision History

时间描述
2016-01-24博文完成

CSDN:http://blog.csdn.net/y550918116j

GitHub:https://github.com/937447974/Blog

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值