2011-02-11 53 views
0
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應用於顯示的內容。我已經嘗試了一個星期,直到現在我 沒有得到解決方案。iphone和ipad epub讀卡器xcode

Thanks in Advance, 

與問候, Suresh.M

+0

你有沒有找到解決方案呢? – Matjan 2013-11-10 13:23:51

回答

1

你可以嘗試這樣的事:

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 ...由費德里科Frappi

乾杯!