AePubReader icon indicating copy to clipboard operation
AePubReader copied to clipboard

Cross links in AePubReader

Open isakvan opened this issue 13 years ago • 3 comments

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.

isakvan avatar Feb 02 '12 16:02 isakvan

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

fedefrappi avatar Feb 02 '12 20:02 fedefrappi

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 avatar Feb 05 '12 07:02 isakvan

Thank you I used you search logic

Bye!

isakvan avatar Feb 06 '12 08:02 isakvan