【问题标题】:How to set image into uiwebview?如何将图像设置为 uiwebview?
【发布时间】:2014-10-30 12:00:01
【问题描述】:

我已经创建了一个如上所示的 html 代码,并将代码上传到http://www.ged.Ic.com 站点。

在 Xcode 项目中添加了图像名称“1.jpg”。

当打开 iPad 应用时,从 webview 加载 http://www.ged.Ic.com/page/

如何将图像从 Xcode 项目设置为 img src="image path from xcode"

【问题讨论】:

    标签: ios iphone xcode webview


    【解决方案1】:
    NSString *imageFileName = @"image";
    NSString *imageFileExtension = @"png";
    
    NSString *imagePath = [[NSBundle mainBundle] pathForResource:imageFileName ofType:imageFileExtension];
    
    NSString *imgHTMLTag = [NSString stringWithFormat:@"<img src=\"file://%@\" />", imagePath];
    

    【讨论】:

      【解决方案2】:
      NSString *imageUrlString = @"http://www.gstatic.com/translate/intl/ru/logo.png";
      NSString *yourText = @"Some text here";
      
      NSString *htmlString = [NSString stringWithFormat:@"<img src='%@'/><br><b>%@</b>", imageUrlString, yourText];    
      [myWebView loadHTMLString:htmlString baseURL:nil];
      

      【讨论】:

        猜你喜欢
        • 2012-02-09
        • 2012-06-11
        • 1970-01-01
        • 2016-01-21
        • 2013-02-02
        • 2014-06-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多