Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 page display #13

Open
jdpecson opened this issue Apr 18, 2012 · 8 comments
Open

2 page display #13

jdpecson opened this issue Apr 18, 2012 · 8 comments

Comments

@jdpecson
Copy link

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

Thank you very much!

@jdpecson
Copy link
Author

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 jdpecson reopened this Apr 18, 2012
@jdpecson
Copy link
Author

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.

@WebberLai
Copy link

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

@javalnanda
Copy link

@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 javalnanda@gmail.com

@javalnanda
Copy link

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];

@dineshprasanna
Copy link

Could you send me your two page sample code
MailID is prasanna.d@greatinnovus.com

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

@javalnanda
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@WebberLai @jdpecson @dineshprasanna @javalnanda and others