ios 4 sdk中支技文档的预览功能,何为预览?就是你打印文件时的预览功能。其用到quicklook.framework,它支持的文档格式有: iWork documents, Microsoft Office, Rich Text Format, PDF, images, text files and comma-separated (csv) files.
今天show一个demo,展示其用法:
第一步:创建一个基于view的工程,并加入quicklook.framewrok
第二步:修改Controller的头文件如下:
- #import <QuickLook/QuickLook.h>
-
- @interface TestViewController : UITableViewController <QLPreviewControllerDataSource>
- {
- NSArray *arrayOfDocuments;
- }
-
- @end
修改 controller执行文件如下
修改Appdelegate如下
- - (void)applicationDidFinishLaunching:(UIApplication *)application
- {
-
- window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
-
-
- vc = [[TestViewController alloc] init];
-
-
- nav = [[UINavigationController alloc] initWithRootViewController:vc];
-
- [window addSubview:[nav view]];
- [window makeKeyAndVisible];
- }
所要的资源文件可以
源码中找到。