UIWebView and local css file

后端 未结 4 531
盖世英雄少女心
盖世英雄少女心 2020-12-13 03:10

I want to style a web page meant for the desktop so that it is presentable on a UIWebView on iPhone. I do not have access to the web server from which the pages originate. I

4条回答
  •  感动是毒
    2020-12-13 04:03

    Your code should work, if you choose index 0 of the found elements:

        NSString *js = @"document.getElementsByTagName('link')[0].setAttribute('href','";
        NSString *js2 = [js stringByAppendingString:cssPath];
        NSString *finalJS = [js2 stringByAppendingString:@"');"];
        [webview stringByEvaluatingJavaScriptFromString:finalJS];
    

    You missed [0]

提交回复
热议问题