Note that there are some explanatory texts on larger screens.

plurals
  1. POwebViewDidFinishLoad does not work for two uiwebviews in one view
    text
    copied!<p>I add two uiwebviews in my Nib,and they load a same html in the documents dictionary.</p> <p>It goes into webViewDidFinishLoad twice,but only one webview's style changed..</p> <p>Thanks,here is my code:</p> <pre><code>- (void)viewDidLoad{ NSString *_pagesPath = [NSHomeDirectory() stringByAppendingFormat:@"/Documents/chapter5.htm"]; web1.delegate = self; [web1 loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:_pagesPath]]]; web2.delegate = self; [web2 loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:_pagesPath]]]; </code></pre> <p>}</p> <pre><code>- (void) webViewDidFinishLoad:(UIWebView*)webView{ 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. "}" "}"; NSString *insertRule2 = [NSString stringWithFormat:@"addCSSRule('p', 'text-align: justify;line-height:3.5')"]; NSString *insertRule3 = [NSString stringWithFormat:@"addCSSRule('body', 'background:#e0d9ca;')"]; [webView stringByEvaluatingJavaScriptFromString:varMySheet]; [webView stringByEvaluatingJavaScriptFromString:addCSSRule]; [webView stringByEvaluatingJavaScriptFromString:insertRule2]; [webView stringByEvaluatingJavaScriptFromString:insertRule3]; </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload