TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Kiran Panesar.
I loved the original version of this project. It was the only decent open source PDF reader for iOS. The one caveat for me was its incredibly dated UI. So with this in mind, I forked the project and optimised the UI for iOS 7 and added a few more necessary tweaks.
Here's a list of the changes I've made for the initial version:
Here's how it looks now:
Cocoapods of course!
pod 'ReaderFramework', '~> 1.1.3'
As mentioned above, you now need to show the ReaderViewController instance in UINavigationController stack. So if you want to push it onto the stack, simply:
-(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];
}
You can also display it modally, but you need to show it in a 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];
}
You can also use ReaderViewController as a subview of a normal UIViewController. This requires extra, slightly obscure setup, so is not the recommended method. With that being said, here's an example:
-(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];
}
This is a fork of Julius Oklamcak's Reader project, so full credit to him for the base work.
This code has been made available under the MIT License.