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

Cross links in AePubReader #6

Open
isakvan opened this issue Feb 2, 2012 · 3 comments
Open

Cross links in AePubReader #6

isakvan opened this issue Feb 2, 2012 · 3 comments

Comments

@isakvan
Copy link

isakvan commented Feb 2, 2012

Hi all,
first thanks to author for nice free code!
I'm using it.

If it correct that this code no supply href to another xml file (<'a href='section-0801.xml'>Look Here<'/a>).

How to do it? Any idea?
Thank you.

@fedefrappi
Copy link
Owner

Hi! We're glad you found our code useful.
You are correct, link handling wasn't implemented, you should take a look at the
– webView:shouldStartLoadWithRequest:navigationType delegate method to detect when the user selects a link and act accordingly.
Here is a link to the related documentation: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebViewDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UIWebViewDelegate

Bye,
Federico

@isakvan
Copy link
Author

isakvan commented Feb 5, 2012

Hi Fedefrappi, thank you very mach!
It works for me fine but to define page in spine for anchors into XML it seems I need to use JavaScript or you search logic or another way?
I get code like this :

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    if (navigationType == UIWebViewNavigationTypeLinkClicked) {

        //path to called chapter
        NSURL* url = [request  URL];

       NSString * newChapterURL = [url path];

        //get chapter index by chapter path
        int indexNewChapter = -1;
        NSString *path;

        for (int i=0; i<loadedEpub.spineArray.count & indexNewChapter == -1; i++) {

            path = ((Chapter*)[loadedEpub.spineArray objectAtIndex:i]).spinePath;

            if([path isEqualToString:newChapterURL]){
                indexNewChapter = i;
            }
        }
        [self loadSpine:indexNewChapter atPageIndex:0];


        return NO;
    }

    return YES;
}

Bye,
Isak

@isakvan
Copy link
Author

isakvan commented Feb 6, 2012

Thank you I used you search logic

Bye!

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

2 participants