나는 로컬 파일을 참조하는 자바 스크립트 실행 stringByEvaluatingJavaScriptFromString를 사용하려면 (이 경우 CSS 파일에,하지만 너무 잠재적 JS 파일) 장치에있는 (문서에는 것 같아요 폴더?) ...로컬 파일을 참조하는 Javascript에서 stringByEvaluatingJavaScriptFromString을 사용할 수 있습니까?
NSString *theJS = [[NSString alloc]
initWithString:@"javascript:(function()
{the_css.rel='stylesheet';
the_css.href='the_css.css';
the_css.type='text/css';
the_css.media='screen';}
)();"];
[webView stringByEvaluatingJavaScriptFromString:theJS];
어떻게 작동합니까? 내가 외부 CSS 파일을 사용하는 경우는 이것은로 번들의 위치를 전달합니다 나는 HTML
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:bundlePath];
[webView loadData:data MIMEType:@"text/html" textEncodingName:@"utf-8 " baseURL:baseURL];
를로드 할 때이 코드를 사용 과거에했던 어떤
the_css.href='http://www.website.com/the_css.css';