第三方框架-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