从IOS4.0后,apple推出新的文件预览控件:QLPreveiewController,已经支持pdf文件阅读。
用法:
1.实现QLPreviewControllerDataSource
#import <Foundation/Foundation.h>
#import <QuickLook/QuickLook.h>
@interface PreviewDataSource : NSObject<QLPreviewControllerDataSource> {
NSString *path;
}
@property (nonatomic, assign) NSString *path;
@end
#import "PreviewDataSource.h"
@implementation PreviewDataSource
@synthesize path;
- (NSInteger) numberOfPreviewItemsInPreviewController: (QLPreviewController *) controller
{
return 1;
}
- (id <QLPreviewItem>)previewController: (QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
{
return [NSURL fileURLWithPath:path];
}
- (void)dealloc {
[path release];
[super dealloc];
}
@end
2.调用方法:
QLPreviewController *previewoCntroller = [[[QLPreviewController alloc] init] autorelease];
PreviewDataSource *dataSource = [[[PreviewDataSource alloc]init] autorelease];
dataSource.path=[[NSString alloc] initWithString:appFile];
previewoCntroller.dataSource=dataSource;
[app.nav pushViewController: previewoCntroller animated:YES];
[previewoCntroller setTitle:fileName];
previewoCntroller.navigationItem.rightBarButtonItem=nil;
分享到:
相关推荐
显示QLPreviewController用法的简单示例项目 这个项目展示了如何使用QLPreviewController来预览各种文件,如 PDF、图像、Word 文档等。 它展示了如何创建自定义QLPreviewItem ,如何配置QLPreviewController显示多个...
NULL 博文链接:https://leobluewing.iteye.com/blog/1614334
本demo使用两种预览方式:UIDocumentInteractionController QLPreviewController 展示文件
支持本来预览Excel文件,点击可放大缩小,支持分享给其他人和分享到其他app.
iOS QLPreviewController 文件预览
QLPreviewController 可以预览以下文件格式: iWork 文档微软办公文档富文本格式 (RTF) 文档PDF 文件(在本例中使用) 图片文本文件CSV 文件QLPreviewController 需要一个数据源对象。 QuickLook 预览控制器可以被...
UIWebView、UIDocumentInteractionController、QLPreviewController三种方式加载PDF等各种格式的文档
iOS 文件预览 RBFilePreviewer ,RBFilePreviewer 是一个封装了 QLPreviewController 的类,简化了使...
优化一点的是用系统的QLPreviewController加载,实现起来也比较方便,支持上下滑动浏览,左后滑动可多PDF文件切换,同时支持原生的分享打印,QLPreviewController支持的文档格式也比较多,如pdf、doc、docx、xls、...
本demo主要是使用了ios自带框架 QuickLook.FrameWork 中的 QLPreviewController来加载显示pdf 、 word 等文本 ,可以保存到icloud文件中,能进行分享等操作 ,可以一下加载多个文本文件进行展示
特征Enpand QLPreviewController 支持远程文件预览。 使用 Alamofire 作为加载文件的依赖项。安装迦太基要使用 Carthage 将 FilePreviewController 集成到您的 Xcode 项目中,请在您的Cartfile指定它: $ github " ...
文档互动样本Xamarin.iOS的文档交互示例,以演示如何在应用程序中使用UIDocumentInteractionController和QLPreviewController 。