AePubReader icon indicating copy to clipboard operation
AePubReader copied to clipboard

2 page display

Open jdpecson opened this issue 12 years ago • 7 comments

Is there a way on how i can make it display on two page on landscape orientation?

Thank you very much!

jdpecson avatar Apr 18 '12 02:04 jdpecson

Here's what I've done to implement this.

Changed this method in EPubViewController.m

  • (void) gotoNextSpine { if(!paginating){ if(currentSpineIndex+1<[loadedEpub.spineArray count]){ [self loadSpine:++currentSpineIndex atPageIndex:0]; CATransition *transition = [CATransition animation]; [transition setDelegate:self]; [transition setDuration:0.5f]; [transition setType:kCATransitionPush]; [transition setSubtype:kCATransitionFromRight]; [self.webView.layer addAnimation:transition forKey:@"PageAnim"]; }
    } }
  • (void) gotoPrevSpine { if(!paginating){ if(currentSpineIndex-1>=0){ [self loadSpine:--currentSpineIndex atPageIndex:0]; CATransition *transition = [CATransition animation]; [transition setDelegate:self]; [transition setDuration:0.5f]; [transition setType:kCATransitionPush]; [transition setSubtype:kCATransitionFromLeft]; [self.webView.layer addAnimation:transition forKey:@"PageAnim"]; }
    } }

and in viewDidLoad I changed this part of the code...

...

UIScrollView* sv = nil; for (UIView* v in webView.subviews) { if([v isKindOfClass:[UIScrollView class]]){ sv = (UIScrollView*) v; sv.scrollEnabled = YES; sv.showsHorizontalScrollIndicator = NO; sv.showsVerticalScrollIndicator = NO; sv.bounces = NO; sv.delegate = self; } }

...

Lastly I added the UIScrollViewDelegate protocol on the header file and implemented this delegate method.

#pragma mark - ScrollView Delegate -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { if (scrollView.contentOffset.x <= 0.0f) { [self gotoPrevSpine]; } else if ((scrollView.contentOffset.x + scrollView.frame.size.width) >= scrollView.contentSize.width) { [self gotoNextSpine]; } }

Viola! One problem though it's pretty fast in scrolling.

jdpecson avatar Apr 18 '12 03:04 jdpecson

I found some issue about going to previous spine, it starts at the first page of the chapter. That's why instead of..

            [self loadSpine:++currentSpineIndex atPageIndex:0];

I changed it to..

            int targetPage = [[loadedEpub.spineArray objectAtIndex:(currentSpineIndex-1)] pageCount];
            [self loadSpine:--currentSpineIndex atPageIndex:targetPage-1];

So it will now go to the last page of the previous chapter.

jdpecson avatar Apr 18 '12 03:04 jdpecson

@jdpecson Can you send me your two page sample code ??? my mail is sendercustom@yahoo.com.tw Thank you

WebberLai avatar May 07 '12 07:05 WebberLai

@jdpecson hey can you plz share a code of two page display in landscape mode ? I am struggling for the same but unable to achieve it. can you send the code for it to [email protected]

javalnanda avatar May 11 '12 05:05 javalnanda

I achieved it by changing the following code in webViewDidFinishLoading of EpubViewController.m

NSString *insertRule1 = [NSString stringWithFormat:@"addCSSRule('html', 'padding: 0px; height: %fpx; -webkit-column-gap: 0px; -webkit-column-width: %fpx;')", webView.frame.size.height, webView.frame.size.width ];

to

NSString *insertRule1 = [NSString stringWithFormat:@"addCSSRule('html', 'padding: 0px; height: %fpx; -webkit-column-gap: 0px; -webkit-column-width: %fpx;')", webView.frame.size.height, webView.frame.size.width / 2];

javalnanda avatar May 11 '12 09:05 javalnanda

Could you send me your two page sample code MailID is [email protected]

please send the code i am handling the critical situation in my project Thank you

dineshprasanna avatar Jun 19 '12 07:06 dineshprasanna

Please find the solution for two page mode in following post : http://stackoverflow.com/questions/11823649/rendering-epub-in-two-page-mode

javalnanda avatar Sep 04 '12 10:09 javalnanda