Error when paginating html in UIWebView using css Multicolumns

Here is my problem:

I am currently writing an e-book reader in objective-c and want to use multi-column pages to split the xhtml file into my webview. Unfortunately, when I add Multicolumns to my css, my html seems to be only 2 "pages long, which is the first two tags

. Does anyone know what I'm doing wrong?

here is the code with which i paste the new settings into my css:

NSString *varMySheet = @"var mySheet = document.styleSheets[0];";

NSString *addCSSRule =  @""
    "function addCSSRule(selector, newRule) {"
        "if (mySheet.addRule) {"
            "mySheet.addRule(selector, newRule);"       // For Internet Explorer
        "} else {"              
            "ruleIndex = mySheet.cssRules.length;"
            "mySheet.insertRule(selector + '{' + newRule + ';}', ruleIndex);"   // For Firefox, Chrome, etc.
        "}" // endif mySheet.addRule
    "}"; // end addCSSRule()    
NSString *insertColumns = [NSString stringWithFormat:@"addCSSRule('div', 'height: 370px; -webkit-column-width: 320px');"];



[wv_reader stringByEvaluatingJavaScriptFromString:varMySheet];

[wv_reader stringByEvaluatingJavaScriptFromString:addCSSRule];

[wv_reader stringByEvaluatingJavaScriptFromString:insertColumns];

For scrolling, I use the following code:

int i_scrollTo = ([AppState sharedInstance].i_myselectedPage -1) * wv_reader.frame.size.height;
[wv_reader stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.scrollTo(0,%d);", i_scrollTo]];

which works fine if I don't set multi-columns in my CSS.

, html - , NSLog - , . , , 79061, css 424 - .

-, , ? .

. Maverick

* UPDATE ** , document.scrollWidth , , .

+3
1

https://github.com/fedefrappi/AePubReader

Maybe this sample can help you?

0
source

Source: https://habr.com/ru/post/1796029/


All Articles