Cannot select individual words with fixed layout .epub documents
Asked Answered
T

1

13

I have a reader app that loads .epub files and usually I have no problem with selection at all, lately I have integrated fixed layout .epub files but I'm facing a problem: when I have a box containing one line the selection works fine, but when the box contains several lines, meaning several <p></p>, I cannot select a single word from the box. On selection the whole box gets selected as shown in the screenshot. When I try the same .epub file on iBooks, the selection works fine on all text. Any idea how I can fix the issue?

Here is the code for loading the file on UiWebView.

NSString *contents = [NSString stringWithContentsOfFile:itemPath encoding:NSUTF8StringEncoding error:nil];
if (!contents) {
    contents = [NSString stringWithContentsOfFile:itemPath encoding:NSASCIIStringEncoding error:nil];
}
[readingWebView loadHTMLString:contents baseURL:baseURL];

enter image description here

enter image description here

Trillbee answered 9/6, 2015 at 7:24 Comment(0)
T
0

I have finally got the answer.

When using this function:

NSString *jsString = [NSString stringWithFormat:@"document.getElementsByTagName('body')[0].webkitTextSizeAdjust= '%d%%'", font];

to set the font size some restrictions are set on the web view, one of them is related to the selection with fixed layout epubs.

I used instead:

NSString *jsString = [NSString stringWithFormat:@"document.getElementsByTagName('body')[0].style.fontSize= '%d%%'", font];
Trillbee answered 11/1, 2017 at 10:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.