readium / SDKLauncher-iOS

A small iOS application to serve as a launcher/testbed for the Readium SDK.
BSD 3-Clause "New" or "Revised" License
71 stars 47 forks source link

Simple Swipe Navigation for EPUB IOS app #90

Closed sage-IT closed 7 years ago

sage-IT commented 7 years ago

This branch allows swpie navigation for the ios app. A very simple commit which only required one page to be modified.

Code Changes:

EPubViewController.m Added: -(void) viewDidLoad{ [super viewDidLoad]; UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightAction:)]; //swipeRight.direction = UISwipeGestureRecognizerDirectionRight; [swipeRight setDirection:UISwipeGestureRecognizerDirectionRight]; //swipeRight.delegate = self; [m_webViewUI addGestureRecognizer:swipeRight]; [m_webViewWK addGestureRecognizer:swipeRight]; UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftAction:)]; //swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft; [swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft]; //swipeLeft.delegate = self; [m_webViewUI addGestureRecognizer:swipeLeft]; [m_webViewWK addGestureRecognizer:swipeLeft];}

And Functions: //Swpie left goes to next page on ePub -(void)swipeLeftAction:(UISwipeGestureRecognizer *) swipe{ [self executeJavaScript:@"ReadiumSDK.reader.openPageNext()" completionHandler:nil]; NSLog(@"%s","Swipe Left");}

//Swipe right goes to previous page on epub -(void)swipeRightAction:(UISwipeGestureRecognizer *) swipe{ [self executeJavaScript:@"ReadiumSDK.reader.openPagePrev()" completionHandler:nil]; NSLog(@"%s","Swipe Right");}

So far no errors have occurred, after testing several times on multiple ePubs, please feel free to check the code and comment back.

Thanks for this awesome framework 👍