显示PDF

UIWebView:方便快捷,因此也就效率慢。
QLPreviewController和UIDocumentInteractionController:底层使用UIWebView,但是提供预览模式。
CGPDFDocument:较底层方法,当然需要不少代码。
[color=red]重要:官方demo->ZoomingPdfViewer(一切都在里面)[/color]
资料:
1、[url]http://stackoverflow.com/questions/4121674/is-there-any-best-way-to-show-pdf-in-iphone-other-than-uiwebview-in-objective-c[/url]
It sounds like you may have some large vector calculations going on in your PDF. You can try re-constructing your PDF with flat images instead of vectors.

Code-wise QLPreviewController should be able to do what you want with a PDF, however it may use a UIWebView underneath. UIDocumentInteractionController also has a preview mode, but I suspect that it is using a QLPreviewController itself for it's preview.

You can also use the low level PDF functions, though this will be more difficult to do. Look at CGPDFDocument and it's related APIs in apple's documentation for more here.

2、[url]http://zhao-zhe.appspot.com/?p=139001[/url]
[color=red]文章在该网页的较底部。多找找。标题是:2,预览pdf等文本文件与图片[/color]

iOS4中新增了类QLPreviewController,可以用于预览iWork documents,MS Documents,RTF,PDF,Images,CSV等文件.它包含在QuickLook.framework中,使用时需要包含头文件<QuickLook/QuickLook.h>.使用QLPreviewController需要实现代理QLPreviewControllerDelegate,QLPreviewControllerDataSource.
//
// YQuickLook.h
// YouX
//
// Created by zhezhao on 10-12-1.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <QuickLook/QuickLook.h>

@interface YQuickLook : NSObject <QLPreviewControllerDelegate,QLPreviewControllerDataSource>{
NSArray *paths;
}

@property (nonatomic, retain) NSArray *paths;

@end
//
// YQuickLook.m
// YouX
//
// Created by zhezhao on 10-12-1.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "YQuickLook.h"


@implementation YQuickLook
@synthesize paths;

- (NSInteger) numberOfPreviewItemsInPreviewController: (QLPreviewController *) controller{
return [paths count];
}

- (id <QLPreviewItem>) previewController: (QLPreviewController *) controller previewItemAtIndex: (NSInteger) index{
NSURL *url = [NSURL fileURLWithPath:[paths objectAtIndex:index]];
return url;
}

- (void)dealloc {
[super dealloc];
[paths release];
}
@end
调用方法:
QLPreviewController *controller = [[QLPreviewController alloc] init];
YQuickLook *quickLook = [[YQuickLook alloc] init];
quickLook.paths = [NSArray arrayWithObjects:attachment.path,nil];
controller.delegate = quickLook;
controller.dataSource = quickLook;
[self.navigationController pushViewController:controller animated:YES];
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值