• <legend id='rs8uY'><style id='rs8uY'><dir id='rs8uY'><q id='rs8uY'></q></dir></style></legend>
  • <i id='rs8uY'><tr id='rs8uY'><dt id='rs8uY'><q id='rs8uY'><span id='rs8uY'><b id='rs8uY'><form id='rs8uY'><ins id='rs8uY'></ins><ul id='rs8uY'></ul><sub id='rs8uY'></sub></form><legend id='rs8uY'></legend><bdo id='rs8uY'><pre id='rs8uY'><center id='rs8uY'></center></pre></bdo></b><th id='rs8uY'></th></span></q></dt></tr></i><div id='rs8uY'><tfoot id='rs8uY'></tfoot><dl id='rs8uY'><fieldset id='rs8uY'></fieldset></dl></div>

      <tfoot id='rs8uY'></tfoot>
        <bdo id='rs8uY'></bdo><ul id='rs8uY'></ul>

      1. <small id='rs8uY'></small><noframes id='rs8uY'>

      2. UIWebView 和本地 css 文件

        时间:2023-10-22

        <small id='WUWvZ'></small><noframes id='WUWvZ'>

      3. <legend id='WUWvZ'><style id='WUWvZ'><dir id='WUWvZ'><q id='WUWvZ'></q></dir></style></legend>
          <bdo id='WUWvZ'></bdo><ul id='WUWvZ'></ul>

            <i id='WUWvZ'><tr id='WUWvZ'><dt id='WUWvZ'><q id='WUWvZ'><span id='WUWvZ'><b id='WUWvZ'><form id='WUWvZ'><ins id='WUWvZ'></ins><ul id='WUWvZ'></ul><sub id='WUWvZ'></sub></form><legend id='WUWvZ'></legend><bdo id='WUWvZ'><pre id='WUWvZ'><center id='WUWvZ'></center></pre></bdo></b><th id='WUWvZ'></th></span></q></dt></tr></i><div id='WUWvZ'><tfoot id='WUWvZ'></tfoot><dl id='WUWvZ'><fieldset id='WUWvZ'></fieldset></dl></div>
              <tbody id='WUWvZ'></tbody>

            1. <tfoot id='WUWvZ'></tfoot>

                • 本文介绍了UIWebView 和本地 css 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想为桌面设计一个网页样式,以便它可以在 iPhone 上的 UIWebView 上显示.我无权访问页面来源的 Web 服务器.我想通过以编程方式更改 <link> 样式表元素的 href 属性来做到这一点.

                  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 would like to do this by changing the href attribute of the <link> stylesheet element programmatically.

                  我使用 IBOutlet UIWebView *webView 执行以下操作.

                  I do the following with my IBOutlet UIWebView *webView.

                  NSString *cssPath = [[NSBundle mainBundle] pathForResource:@"MyStyleSheet" 
                                                                      ofType:@"css"];
                  NSString *js = @"document.getElementsByTagName('link').setAttribute('href','";
                  NSString *js2 = [js stringByAppendingString:cssPath];
                  NSString *finalJS = [js2 stringByAppendingString:@"');"];
                  
                  //check element structure
                  NSString *res = [webView stringByEvaluatingJavaScriptFromString:finalJS]; 
                  

                  这不起作用.使用 [webView stringByEvaluatingJavaScriptFromString:] 消息并更改正文的 backgroundColor 确实有效 - 作为练习来查看我是否正确使用了调用.

                  This does not work. Using the [webView stringByEvaluatingJavaScriptFromString:] message and making a change to the backgroundColor of the body does indeed work - done as an exercise to see if I was using the call correctly.

                  我是不是找错树了?

                  推荐答案

                  可以从本地项目目录加载CSS

                  You can load CSS from local project directory

                  NSString *path = [[NSBundle mainBundle] bundlePath];
                  NSURL *baseURL = [NSURL fileURLWithPath:path];
                  [webView loadHTMLString:htmlString baseURL:baseURL];
                  

                  详情请查看本站:http://iphoneincubator.com/blog/windows-views/uiwebview-revisited

                  这篇关于UIWebView 和本地 css 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:UIWebView EXC_BAD_ACCESS 崩溃 下一篇:如何设置“用户代理"?Swift 中 UIWebView 的标头

                  相关文章

                  • <bdo id='AFTKv'></bdo><ul id='AFTKv'></ul>

                    <legend id='AFTKv'><style id='AFTKv'><dir id='AFTKv'><q id='AFTKv'></q></dir></style></legend>

                      <tfoot id='AFTKv'></tfoot>

                      <i id='AFTKv'><tr id='AFTKv'><dt id='AFTKv'><q id='AFTKv'><span id='AFTKv'><b id='AFTKv'><form id='AFTKv'><ins id='AFTKv'></ins><ul id='AFTKv'></ul><sub id='AFTKv'></sub></form><legend id='AFTKv'></legend><bdo id='AFTKv'><pre id='AFTKv'><center id='AFTKv'></center></pre></bdo></b><th id='AFTKv'></th></span></q></dt></tr></i><div id='AFTKv'><tfoot id='AFTKv'></tfoot><dl id='AFTKv'><fieldset id='AFTKv'></fieldset></dl></div>

                      <small id='AFTKv'></small><noframes id='AFTKv'>