iphone и ipad epub reader для xcode - PullRequest
       1

iphone и ipad epub reader для xcode

0 голосов
/ 11 февраля 2011
 I have done the followings in objective c and javascript,

    1. extract the epub file using unzip library.
    2. parse the .opf file to get the .xhtml files .
    3. Using navigation tab i have display the contents like plain text .
    4. Each page javascript to display contents in page by page to the html.
    5. i finished the page flip also works fine.

I have to implement the followings,

    1.Apply CSS to the html contents like iBooks

Кто-нибудь знает, как применить CSS к отображаемому содержимому.Я пытался одну неделю до сих пор, я не получил решение.

 Thanks in Advance,

С уважением, Суреш.М

1 Ответ

1 голос
/ 14 февраля 2012

Вы можете попробовать что-то вроде этого:

    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.
"}"
"}";

    // NSLog(@"w:%f h:%f", webView.bounds.size.width, webView.bounds.size.height);

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];
NSString *insertRule2 = [NSString stringWithFormat:@"addCSSRule('p', 'text-align: justify;')"];
NSString *setTextSizeRule = [NSString stringWithFormat:@"addCSSRule('body', '-webkit-text-size-adjust: %d%%;')",fontPercentSize];

Я получил этот код от AePubReader ... от Федерико Фраппи

Приветствия!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...