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

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

        <legend id='Ni7hN'><style id='Ni7hN'><dir id='Ni7hN'><q id='Ni7hN'></q></dir></style></legend>
      1. 在本地 HTML 文件中加载图像 -- UIWebView

        Load image in local HTML file -- UIWebView(在本地 HTML 文件中加载图像 -- UIWebView)
          <bdo id='9eAlO'></bdo><ul id='9eAlO'></ul>
          1. <tfoot id='9eAlO'></tfoot>
              <tbody id='9eAlO'></tbody>
            <legend id='9eAlO'><style id='9eAlO'><dir id='9eAlO'><q id='9eAlO'></q></dir></style></legend>

              <small id='9eAlO'></small><noframes id='9eAlO'>

                  <i id='9eAlO'><tr id='9eAlO'><dt id='9eAlO'><q id='9eAlO'><span id='9eAlO'><b id='9eAlO'><form id='9eAlO'><ins id='9eAlO'></ins><ul id='9eAlO'></ul><sub id='9eAlO'></sub></form><legend id='9eAlO'></legend><bdo id='9eAlO'><pre id='9eAlO'><center id='9eAlO'></center></pre></bdo></b><th id='9eAlO'></th></span></q></dt></tr></i><div id='9eAlO'><tfoot id='9eAlO'></tfoot><dl id='9eAlO'><fieldset id='9eAlO'></fieldset></dl></div>
                  本文介绍了在本地 HTML 文件中加载图像 -- UIWebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 UIWebView 中加载本地 HTML 文件,如下所示:

                  I load a local HTML file in a UIWebView like so:

                  [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]isDirectory:NO]]];    
                  

                  在我的 index.html 中,如何使用 img src="..."/> 加载显示本地图像(通过 Xcode 添加到项目中)?

                  In my index.html, how do I load a display a local image (added to project through Xcode) with img src="..."/> ?

                  推荐答案

                  不使用 NSURLRequest 加载,而是将 html 文件读入 NSString 并创建一个 NSURL 到带有图像文件的目录.

                  Instead of loading with an NSURLRequest, read the html file into an NSString and create an NSURL to the directory with image files.

                  然后使用 UIWebView 的 - (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL 方法.

                  Then use UIWebView's - (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL method.

                  所以,你会有类似...

                  So, you'd have something like...

                  NSURL *url = [[NSBundle mainBundle] URLForResource:@"index" withExtension:@"html"];
                  NSString *html = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
                  
                  [webView loadHTMLString:html baseURL:[url URLByDeletingLastPathComponent]];
                  

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

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                  Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)
                  Resume game cocos2d(恢复游戏 cocos2d)
                  Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))
                  Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
                  How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)

                    <bdo id='rHfEv'></bdo><ul id='rHfEv'></ul>
                      <legend id='rHfEv'><style id='rHfEv'><dir id='rHfEv'><q id='rHfEv'></q></dir></style></legend>

                        1. <tfoot id='rHfEv'></tfoot>
                          • <small id='rHfEv'></small><noframes id='rHfEv'>

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