• UIWebView中加载本地图片


    UIWebView中加载本地图片
    - (void)viewDidLoad { [super viewDidLoad]; UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds]; webView.delegate = self; [webView loadHTMLString:@"<html><head></head><body><img class='test' width=100% height=100% src=''></body></html>" baseURL:nil]; [self.view addSubview:webView]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - UIWebViewDelegate methods -(void)webViewDidFinishLoad:(UIWebView *)webView{ NSString *imagePath = [[NSBundle mainBundle] resourcePath]; imagePath = [imagePath stringByReplacingOccurrencesOfString:@"/" withString:@"//"]; imagePath = [imagePath stringByReplacingOccurrencesOfString:@" " withString:@"%20"]; imagePath = [NSString stringWithFormat:@"file:/%@//%@",imagePath,@"test.png"]; NSString * js = [NSString stringWithFormat:@"document.images[0].src='%@'",imagePath]; [webView stringByEvaluatingJavaScriptFromString:js]; NSString *path = [webView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML"]; NSLog(@"%@",path); }
  • 相关阅读:
    3.for in循环
    2.break与continue
    1.XHTML框架结构
    lamda表达式在EF中的应用
    View数据呈现相关技术
    ASP.NET MVC 4 技术讲解
    ASP.NET MVC 相关的社群与讨论区
    C# 随机红包算法
    圆圈里带 小写字母,大写字母
    使用SQL语句 检测 MSSQL死锁
  • 原文地址:https://www.cnblogs.com/ios988/p/8124422.html
Copyright © 2020-2023  润新知