成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

iPhone開發(fā)應(yīng)用中PDF案例實現(xiàn)

移動開發(fā) iOS
iPhone開發(fā)應(yīng)用中PDF案例實現(xiàn)是本文要介紹的內(nèi)容,主要是來學(xué)習(xí)iPhone開發(fā)中PDF的解析內(nèi)容,文章內(nèi)容不多,主要是基于代碼來實現(xiàn)。來看詳細(xì)內(nèi)容。

iPhone開發(fā)應(yīng)用中PDF案例實現(xiàn)是本文要介紹的內(nèi)容,主要是來學(xué)習(xí)iPhone開發(fā)PDF的解析內(nèi)容,文章內(nèi)容不多,主要是基于代碼來實現(xiàn)。來看詳細(xì)內(nèi)容。

  1. #import <UIKit/UIKit.h> 
  2. @class PDFTestViewController;  
  3. @interface PDFView : UIView {  
  4.  //這個類封裝了PDF畫圖得所有信息  
  5.  CGPDFDocumentRef pdf;  
  6.  //PDFDocument 中得一頁  
  7.  CGPDFPageRef page;  
  8.  //總共頁數(shù)  
  9.  int totalPages;  
  10.  //當(dāng)前得頁面  
  11.  int currentPage;  
  12.  PDFTestViewController *pdftest;  
  13. }  
  14. @property(nonatomic,retain)IBOutlet PDFTestViewController *pdftest;  
  15. //當(dāng)前視圖初始化類,在該方法中會創(chuàng)建一個CGPDFDocuemntRef對象,傳遞一個PDF文件得名字,和所需要頁面得大小,  
  16. - (id)initWithFrame:(CGRect)frame andFileName:(NSString *)fileName;  
  17. //創(chuàng)建一個PDF對象,此方法在初始化方法中被調(diào)用  
  18. - (CGPDFDocumentRef)createPDFFromExistFile:(NSString *)aFilePath;  
  19.  
  20. -(void)reloadView;  
  21. /*  
  22.  頁面之間得跳轉(zhuǎn)  
  23.  */  
  24. -(void)goUpPage;     
  25. -(void)goDownPage;  
  26. @end  
  27. //  
  28. //  PDFView.m  
  29. //  PDFViewTest  
  30. //  
  31. //  Created by Evan Lynn on 10-6-20.  
  32. //  Copyright 2010 Tera Age. All rights reserved.  
  33. //  
  34.  
  35. #import "PDFView.h"  
  36.  
  37. //#import "PDFTestViewController.h"  
  38. @implementation PDFView  
  39. @synthesize pdftest;  
  40. - (id)initWithFrame:(CGRect)frame andFileName:(NSString *)fileName{  
  41.  if (self = [super initWithFrame:frame]) {  
  42.  NSString *dataPathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:fileName];  
  43.  pdf = [self createPDFFromExistFile:dataPathFromApp];  
  44.  self.backgroundColor = [UIColor clearColor];  
  45.  }  
  46.  return self;  
  47. }  
  48. - (CGPDFDocumentRef)createPDFFromExistFile:(NSString *)aFilePath{  
  49.  CFStringRef path;  
  50.  CFURLRef url;  
  51.  CGPDFDocumentRef document;  
  52. path = CFStringCreateWithCString(NULL, [aFilePath UTF8String], kCFStringEncodingUTF8);  
  53. url = CFURLCreateWithFileSystemPath(NULL, path, kCFURLPOSIXPathStyle, NO);  
  54.  CFRelease(path);  
  55. document = CGPDFDocumentCreateWithURL(url);  
  56.  CFRelease(url);  
  57. totalPages = CGPDFDocumentGetNumberOfPages(document);  
  58. currentPage=1;  
  59. if (totalPages == 0) {  
  60. return NULL;  
  61. }  
  62. return document;  
  63. }  
  64. - (void)drawRect:(CGRect)rect {  
  65. //得到繪圖上下文環(huán)境  
  66.     CGContextRef context = UIGraphicsGetCurrentContext();  
  67. //得到一個PDF頁面  
  68.     page = CGPDFDocumentGetPage(pdf, currentPage);  
  69. /*進行坐標(biāo)轉(zhuǎn)換向右移動100個單位,并且向下移動當(dāng)前視圖得高度,  
  70. 這是因為Quartz畫圖得坐標(biāo)系統(tǒng)是以左下角為開始點,但iphone視圖是以左上角為開始點  
  71.  */  
  72.     CGContextTranslateCTM(context, 100.0,self.bounds.size.height);  
  73. //轉(zhuǎn)變坐標(biāo)系  
  74.     CGContextScaleCTM(context, 1.0, -1);  
  75.     CGContextDrawPDFPage(context, page);  
  76. }  
  77. - (void)dealloc {  
  78.     [super dealloc];  
  79. }  
  80. -(void)reloadView{  
  81. [self setNeedsDisplay];  
  82. }  
  83. -(void)goUpPage{  
  84. if(currentPage < 2)  
  85. return;  
  86. --currentPage;  
  87. [self reloadView];  
  88. }  
  89. -(void)goDownPage{  
  90. if(currentPage >=totalPages)  
  91. return;  
  92. ++currentPage;  
  93. [self reloadView];  
  94. }  
  95. @end 

小結(jié):iPhone開發(fā)應(yīng)用中PDF案例實現(xiàn)的內(nèi)容介紹完了,希望通過本文的學(xué)習(xí)能對你有所幫助!

責(zé)任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2011-08-18 16:24:44

iPhone開發(fā)圖片

2011-08-16 15:48:37

iPhone開發(fā)抓圖程序

2011-08-19 11:10:31

iPhone應(yīng)用

2011-08-19 10:13:05

iPhone開發(fā)

2011-08-18 15:24:40

iPhone國際化

2011-08-19 10:05:30

iPhone開發(fā)

2011-08-17 16:12:20

iPhone應(yīng)用程序

2011-08-18 16:42:07

iPhone應(yīng)用APNS推送

2011-08-15 11:23:41

iPhone開發(fā)循環(huán)滾動UIScrollVie

2011-08-15 18:02:32

iPhone開發(fā)表視圖

2011-08-10 17:37:00

iPhoneASIHTTPRequ

2011-08-16 15:36:47

iPhone應(yīng)用測試

2011-08-22 14:12:48

iPhone開發(fā)NSTableView

2011-08-15 11:37:20

iPhone開發(fā)Mask

2011-08-17 16:23:31

iPhone開發(fā)UIViewContr

2011-08-09 17:12:30

iPhoneCFRunLoop

2011-08-12 14:33:06

iPhone緩存文件

2012-04-26 13:26:58

iPhone應(yīng)用技巧

2011-08-15 13:50:06

IPhone開發(fā)UIView動畫

2011-08-05 13:49:53

iPhone 應(yīng)用 開發(fā)
點贊
收藏

51CTO技術(shù)棧公眾號

主站蜘蛛池模板: 国产精品www | 国产精品久久av | 中文字幕一级毛片视频 | 日韩精品在线免费 | 色资源在线| 精品成人av | 91大神xh98xh系列全部 | 亚洲一区二区三区视频在线 | 五月网婷婷 | 日本a视频 | 免费成人在线网 | 欧美性另类 | 国产99久久久国产精品 | 久久精品无码一区二区三区 | 亚洲人人 | 久久伊人亚洲 | 色综合久 | 久久国产精品精品 | 九九精品视频在线 | 久久久久久国模大尺度人体 | 日韩中文字幕免费在线 | 97伦理电影网 | 精品久久久久一区二区国产 | 国内自拍偷拍 | 欧美一级全黄 | 午夜在线影院 | 日韩在线观看中文字幕 | jav成人av免费播放 | 久久精品色欧美aⅴ一区二区 | 精品久久久久久久久久久久久久 | 在线观看免费毛片 | 国产精品久久二区 | 91免费电影 | 中文字幕第一页在线 | 日韩在线视频一区 | 999久久久久久久久6666 | 国产九九精品 | 国产福利在线 | 久久久久国产精品一区二区 | 成人免费小视频 | 99久久99 |