第三方框架-PDFViewer的使用


04.PDFViewer学习笔记

第1步:下载第三方框架 PDFViewer,下载地址:https://github.com/vfr/Reader

第2步:导入PDFViewer依赖的iOS框架
MessageUI.framework:发邮件用的,可以把PDF通过邮件的方式发给自己的好友
ImageIO.framework:图像底层的输入输出的接口,
QuartzCore.framework:绘图的时候用

第3步:往项目中导入Classes和Sources,

如果需要打印功能,需要往工程的Supporting Files下导入Graphics文件夹,导入后就自动支持PDF打印功能。

第4步:往控制器中引入PDFViewer的头文件

#import "ReaderViewController.h"
@interface MJViewController () <ReaderViewControllerDelegate>

第5步:开始使用

#import "MJViewController.h"
#import "ReaderViewController.h"

@interface MJViewController () <ReaderViewControllerDelegate>

@end

@implementation MJViewController

- (IBAction)click:(id)sender
{
    // 1. 实例化控制器
    NSString *path = [[NSBundle mainBundle] pathForResource:@"MobileHIG_iOS7_中文.pdf" ofType:nil];
    ReaderDocument *doc = [[ReaderDocument alloc] initWithFilePath:path password:nil];
    ReaderViewController *rvc = [[ReaderViewController alloc] initWithReaderDocument:doc];
    
    rvc.delegate = self;
    
    // 2. 显示ViewController
    [self presentViewController:rvc animated:YES completion:nil];
}

- (void)dismissReaderViewController:(ReaderViewController *)viewController
{
    [self dismissViewControllerAnimated:YES completion:nil];
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM