【问题标题】:Load document directory image into web view [closed]将文档目录图像加载到 Web 视图中 [关闭]
【发布时间】:2012-09-04 05:39:49
【问题描述】:

我有一个带有UIWebView 的 Xcode 项目。现在我需要将图像从文档目录加载到该 web 视图。我怎样才能做到这一点?

【问题讨论】:

    标签: iphone uiwebview uiimage


    【解决方案1】:
     NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
    
        NSString *documentsDirectory = [paths objectAtIndex:0];
    
        NSString  *imagePath = [documentsDirectory stringByAppendingPathComponent: 
                              [NSString stringWithFormat: @"/imageName.png"]];
    
    
        [myWebView loadHTMLString:[NSString stringWithFormat:@"<html><body><img src=\"file://%@\"></body></html>",imagePath] baseURL:nil];
    

    【讨论】:

    • 这不行!!!
    • 它有效...您可能需要在 info.plist 中添加 ATS 异常
    猜你喜欢
    • 1970-01-01
    • 2012-03-31
    • 2012-01-27
    • 2015-01-07
    • 2015-08-08
    • 1970-01-01
    • 2012-07-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多