基于使用 OHPDFImage https://github.com/AliSoftware/OHPDFImage 显示 PDF 文件的垂直滚动视图。
简单地将 GDPDFVIew 文件夹及其文件添加到您的项目中,或者使用 CocoaPods。
platform :ios, '8.0'
use_frameworks!
target 'project_name' do
pod 'GDPDFView', '~> 1.0.4'
end
您可以使用 GDPDFView 与 IB 或代码一起使用。
将一个 UIView 实例添加到您的视图控制器,并将其类更改为 GDPDFView。
然后,在代码中您可以设置
[self.lecturePDFView setPDFViewDelegate:self];
并设置 PDF 文件路径 URL
NSString *path = [[NSBundle mainBundle] pathForResource:@"MyCoreLocationLecture" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:path];
[self.lecturePDFView setFilePathURL:url];
NSString *path = [[NSBundle mainBundle] pathForResource:@"MyCoreLocationLecture" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:path];
self.lecturePDFView = [[GDPDFView alloc] initWithFilePathURL:url];
[self.lecturePDFView setPDFViewDelegate:self];
[self.lecturePDFView setFrame:self.view.bounds];
[self.view insertSubview:self.lecturePDFView atIndex:0];
/**
Indicates when PDF file begin loading
*/
- (void)PDFViewDidBeginLoading:(id<GDPDFViewProperties, GDPDFContainerViewProperties>)view;
/**
Indicates when PDF file end loading and content is ready
*/
- (void)PDFViewDidEndLoading:(id<GDPDFViewProperties, GDPDFContainerViewProperties>)view;
/**
Indicates when current page number is changed, page numbering begins from 0
*/
- (void)PDFView:(id<GDPDFViewProperties, GDPDFContainerViewProperties>)view didChangePage:(NSInteger)pageNumber;
/**
Indicates when new PDF page is created, vectorImage object of OHVectormImage can be customized using class properties
*/
- (void)PDFView:(id<GDPDFViewProperties, GDPDFContainerViewProperties>)view configurePageVectorImage:(OHVectorImage *)vectorImage atPageNumber:(NSInteger)pageNumber;
有关更多详细信息,请查看示例项目。
GDPDFView 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。