ReaderFramework 1.1.4

ReaderFramework 1.1.4

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布日期最后发布2014年12月

Kiran Panesar 维护。



iOS 7的PDF Reader Core

介绍

我非常喜欢这个项目的原始版本。这是iOS上唯一一个体面的开源PDF阅读器。对我来说唯一的缺点是其界面极其过时。所以我想到了这个项目,并为iOS 7优化了界面,并添加了一些必要的调整。

新特性

以下是我在初始版本中进行的更改列表

  • 针对iOS 7风格的UI进行了优化。
  • 根据 此拉取请求 实现了快速翻页。
  • 去除顶部工具栏的ReaderMainToolbar,现在查看器使用当前的 UINavigationController 的 nav bar。 注意:这意味着查看器需要被显示在 UINavigationController 的实例中。请参见以下内容。
  • 去除杂乱的栏按钮项,改为两个 UIBarButtonItems。
  • 添加了在其他应用程序中打开PDF的能力。
  • 将所有框架文件移动到专用文件夹(ReaderFramework)中。
  • 将资源移动到 /ReaderFramework 中的 Reader.bundle 文件中。
  • 为iPad操作添加了UIPopover方法(请参见 此处)。
  • 添加了在UIViewController的子视图中嵌入ReaderViewController的可视化的能力(并仍然支持nav bar)。

以下是现在的样子

iPod Page iPod Page iPod Page

安装

当然是Cocoapods!

pod 'ReaderFramework', '~> 1.1.3'

用法

如上所述,您现在需要在 UINavigationController 栈中显示 ReaderViewController 实例。所以如果要将它推进到栈中,您只需

-(void)pushShowPDFReader:(id)sender {
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"mydocument" ofType:@"pdf"];
    ReaderDocument *document = [ReaderDocument withDocumentFilePath:filePath password:phrase];

    ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
    readerViewController.delegate = self;

    [self.navigationController pushViewController:readerViewController animated:YES];
}

您也可以以模式显示它,但您需要在 UINavigationController 中显示它

-(void)pushShowPDFReaderModally:(id)sender {

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"mydocument" ofType:@"pdf"];
    ReaderDocument *document = [ReaderDocument withDocumentFilePath:filePath password:phrase];

    ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
    readerViewController.delegate = self;

    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:readerViewController];

    [self presentViewController:navigationController animated:YES completion:nil];
}

替代用法

您还可以将ReaderViewController用作正常UIViewController的子视图。这需要额外的、略微神秘的设置,因此不是推荐的方法。话虽如此,下面是一个示例

-(void)addReaderToView:(id)sender {

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"mydocument" ofType:@"pdf"];
    ReaderDocument *document = [ReaderDocument withDocumentFilePath:filePath password:phrase];

    _readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
    _readerViewController.delegate = self;
    _readerViewController.remoteNavigationItem = self.navigationItem;
    _readerViewController.remoteNavigationController = self.navigationController;

    [self.view addSubview:_readerViewController.view];

}

// IMPORTANT:
// You will need to notify ReaderViewController when the view state changes.

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [_readerViewController viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [_readerViewController viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [_readerViewController viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    [_readerViewController viewDidDisappear:animated];
}

致谢

这是Julius Oklamcak的 Reader 项目的分支,所以要对他的基础工作给予全部赞誉。

许可证

此代码已在MIT许可证下发布。