简体   繁体   中英

Display Epub Contnet based on the device view size

I am working in epub reader Creation. following things i did,

  1. Unzip the .epub file

  2. From that I read table of content based on the .ncx file

  3. I display the content uiwebview.(If I want display chapter-1 means chapter-1.xml file full content shown in webview scrollable state).

  4. I used UISwipeGestureRecognizer for page navigation based on the .opf file.

based on those things i can see the .epub file in uiwebview scrollable state.

Now I want to do following things (in uiwebview):

1.To display the content based on the view size.

2.To display number of columns based on the user requirement.

3.To display the page numbers accordingly.

1) for your first question as per i know you want display page according to your size

try with this java script

In webViewDidFinishLoad

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) for counting page in your chapter

 In webViewDidFinishLoad

 int totalWidth = [[_webview stringByEvaluatingJavaScriptFromString:@"document.documentElement.scrollWidth"] intValue];
    ttlChapterPage = (int)((float)totalWidth/_webview.bounds.size.width);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM