123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- //
- // PDFBOTAViewController.m
- // PDFReader
- //
- // Copyright © 2014-2022 PDF Technologies, Inc. All Rights Reserved.
- //
- // The PDF Reader Sample applications are licensed with a modified BSD license.
- // Please see License for details. This notice may not be removed from this file.
- //
- #import "PDFBOTAViewController.h"
- #import "PDFAnnotationListViewController.h"
- #import "PDFOutlineViewController.h"
- #import "PDFBookmarkViewController.h"
- #import "PDFThumbnailViewController.h"
- @interface PDFBOTAViewController () <UIPopoverPresentationControllerDelegate>
- @property (nonatomic,assign) IBOutlet UISegmentedControl *segmentedControl;
- @property (nonatomic,retain) UIViewController *currentViewController;
- @property (nonatomic,retain) PDFAnnotationListViewController *annotationViewController;
- @property (nonatomic,retain) PDFOutlineViewController *outlineViewController;
- @property (nonatomic,retain) PDFBookmarkViewController *bookmarkViewController;
- @property (nonatomic,retain) PDFThumbnailViewController *thumbnailViewController;
- @end
- @implementation PDFBOTAViewController
- #pragma mark - Init Methods
- - (void)dealloc {
- [_annotationViewController release];
- [_outlineViewController release];
- [_bookmarkViewController release];
- [_thumbnailViewController release];
- [_currentViewController release];
- [super dealloc];
- }
- #pragma mark - Getter Methods
- - (PDFAnnotationListViewController *)annotationViewController {
- if (!_annotationViewController) {
- _annotationViewController = [[PDFAnnotationListViewController alloc] init];
- _annotationViewController.pdfViewController = self.pdfViewController;
- [self addChildViewController:_annotationViewController];
- }
- return _annotationViewController;
- }
- - (PDFOutlineViewController *)outlineViewController {
- if (!_outlineViewController) {
- _outlineViewController = [[PDFOutlineViewController alloc] init];
- _outlineViewController.pdfViewController = self.pdfViewController;
- [self addChildViewController:_outlineViewController];
- }
- return _outlineViewController;
- }
- - (PDFBookmarkViewController *)bookmarkViewController {
- if (!_bookmarkViewController) {
- _bookmarkViewController = [[PDFBookmarkViewController alloc] init];
- _bookmarkViewController.pdfViewController = self.pdfViewController;
- [self addChildViewController:_bookmarkViewController];
- }
- return _bookmarkViewController;
- }
- - (PDFThumbnailViewController *)thumbnailViewController {
- if (!_thumbnailViewController) {
- _thumbnailViewController = [[PDFThumbnailViewController alloc] init];
- _thumbnailViewController.pdfViewController = self.pdfViewController;
- [self addChildViewController:_thumbnailViewController];
- }
- return _thumbnailViewController;
- }
- #pragma mark - UIViewController Methods
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- // Do any additional setup after loading the view from its nib.
- self.navigationItem.titleView = self.segmentedControl;
- [self segmentedControlValueChanged_BOTA:nil];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
-
- self.navigationController.navigationBar.translucent = NO;
- }
- #pragma mark - Button Actions
- - (IBAction)segmentedControlValueChanged_BOTA:(id)sender {
- [self.currentViewController.view removeFromSuperview];
-
- if (self.segmentedControl.selectedSegmentIndex == 0) {
- self.currentViewController = self.annotationViewController;
- [self.view addSubview:self.annotationViewController.view];
- self.annotationViewController.view.frame = self.view.bounds;
- self.annotationViewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
- } else if (self.segmentedControl.selectedSegmentIndex == 1) {
- self.currentViewController = self.outlineViewController;
- [self.view addSubview:self.outlineViewController.view];
- self.outlineViewController.view.frame = self.view.bounds;
- self.outlineViewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
- } else if (self.segmentedControl.selectedSegmentIndex == 2) {
- self.currentViewController = self.bookmarkViewController;
- [self.view addSubview:self.bookmarkViewController.view];
- self.bookmarkViewController.view.frame = self.view.bounds;
- self.bookmarkViewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
- } else if (self.segmentedControl.selectedSegmentIndex == 3) {
- self.currentViewController = self.thumbnailViewController;
- [self.view addSubview:self.thumbnailViewController.view];
- self.thumbnailViewController.view.frame = self.view.bounds;
- self.thumbnailViewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
- }
- }
- #pragma mark - Public Methods
- - (void)showViewController:(UIViewController *)viewController inBarButtonItem:(UIBarButtonItem *)barButtonItem {
- UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self];
- nav.modalPresentationStyle = UIModalPresentationPopover;
- UIPopoverPresentationController *popVC = nav.popoverPresentationController;
- popVC.delegate = self;
- popVC.barButtonItem = barButtonItem;
- popVC.permittedArrowDirections = UIPopoverArrowDirectionUp;
- [viewController presentViewController:nav animated:YES completion:nil];
- [nav release];
- }
- #pragma mark - UIPopoverPresentationControllerDelegate
- - (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection {
- return UIModalPresentationNone;
- }
- @end
|