1
두 번째 uiwebviews를 내 펜촉에 추가하고 문서 사전에 같은 html을로드합니다.하나의보기에서 두 개의 uiwebviews에 대해 webViewDidFinishLoad가 작동하지 않습니다.
그것은 두 번 webViewDidFinishLoad로 전환하지만, 단 하나 개의 웹보기의 스타일을 변경 ..
감사합니다, 여기에 내 코드입니다 :
- (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]]];
}
- (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];
}
덕분에, 내가 여기 솔루션을 가지고 : HTTP : //double-slash.net/2010/10/18/using-multiple-ios -uiwebview-objects / – user1114574