zoukankan      html  css  js  c++  java
  • iOS加载HTML, CSS代码

     1     NSString *strHTML = @"<div style="text-align:center;"><img src="/Uploads/Editor/2016-11-20/5830edeb561bd.jpg" alt="" /></div><div style="text-align:center;"><br /></div>";
     2 //    NSString *strHTML = model.goods_datails;
     3     NSMutableString *targerStr = [[NSMutableString alloc] initWithString:strHTML];
     4 //
     5     // 搜索制定字符 在指定位置插入字符串
     6     NSRange range;
     7     range = [targerStr rangeOfString:@"/Uploads/"];
     8     if (range.location != NSNotFound) {
     9 //        NSLog(@"found at location = %lu, length = %lu",(unsigned long)range.location,(unsigned long)range.length);
    10         [targerStr insertString:@"http://xiezhongyunshang.com" atIndex:range.location];
    11         strHTML = targerStr;
    12         NSMutableString *html = [NSMutableString string];
    13         
    14         [html appendString:@"<html>"];
    15         [html appendString:@"<head>"];
    16         [html appendString:@"<style>"];
    17         [html appendString:@"</style>"];
    18         [html appendString:@"</head>"];
    19         [html appendString:@"<body style="font-size:14px">"];
    20         [html appendString:strHTML];
    21         [html appendString:@"</body>"];
    22         
    23         [html appendString:@"</html>"];
    24 
    25         // 设置webView 
    26         detailView.webView.delegate = self;
    27         detailView.webView.dataDetectorTypes = UIDataDetectorTypeAll;
    28         detailView.webView.scalesPageToFit = YES;
    29         // 加载HTML 
    30         [detailView.webView loadHTMLString:html baseURL:[NSURL fileURLWithPath: [[NSBundle mainBundle] bundlePath]]];
    31         [self.mainScrollView addSubview:detailView];
  • 相关阅读:
    zmodem协议的使用(SecureCRT)
    Centos6.5下安装php
    CentOS6.5下Mysql数据库的安装与配置
    YUM更换源--yum找不到安装包(转)
    百度Ueditor编辑器的Html模式自动替换样式的解决方法
    TextArea里Placeholder换行问题
    tp可用的超强第三方图表类库-JpGraph
    确保 PHP 应用程序的安全
    在线网站速度测试
    几款整站抓取的工具
  • 原文地址:https://www.cnblogs.com/crazygeek/p/6096583.html
Copyright © 2011-2022 走看看