iOS_UIWebView加载Html乱码文件
发布日期:2021-05-10 10:08:19 浏览次数:22 分类:精选文章

本文共 2714 字,大约阅读时间需要 9 分钟。

WKWebView���UIWebView���������Html���������������������������������

��������������������������������������������������������������������������� Html ��������������������������������������������������� WKWebView ������������ Html ��������������������������������������������������������������������������������������������������� UIWebView ������������ Html ���������������������������������������������������������������������������������������������������������������������������������������������

���������������������������������������������������������������������������

UIWebView������������Html���������������������������

������������ UIWebView ������������ Html ������������������������������������������������������������������������

  • ��������������������������� UIWebView ���������������������������������������������������������������������
  • UIWebView *view = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, BXScreenW, BXScreenH)];
    1. ������������������ NSBundle ��������� Html ��������������������������������������������������������������� Html ������������������������������������������������������������������������������
    2. NSString *path = [[NSBundle mainBundle] pathForResource:@"������������" ofType:@"html"];
      NSURL *url = [NSURL fileURLWithPath:path];
      1. ��������������������������� NSString ��������� Html ���������������������������������������������������������������������������������������������������������������������
      2. NSStringEncoding * usedEncoding = nil;
        NSString *body = [NSString stringWithContentsOfURL:url usedEncoding:usedEncoding error:nil];
        1. ��������������������������������������������������������������������������������������� GBK ������������������������������������������
        2. if (!body) {
          NSLog(@"GBK������");
          body = [NSString stringWithContentsOfURL:url encoding:0x80000632 error:nil];
          }
          1. ������������������������������������������������������������������������������������ GB18030 ���������������������������������������������������
          2. if (!body) {
            NSLog(@"GBK18030������");
            body = [NSString stringWithContentsOfURL:url encoding:0x80000631 error:nil];
            }
            1. ������������������������������������������������������������������������ UIWebView ���������������������������
            2. if (body) {
              [view loadHTMLString:body baseURL:nil];
              } else {
              NSLog(@"���������������������");
              }
              1. ������������������������ UIWebView ������������������������������������������������������
              2. [self.view addSubview:view];

                ���������������

                ��������� Html ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

    上一篇:iOS_XIB绘制边框颜色
    下一篇:iOS_WKWebView加载工程内Bundle里面的文件,文件路径包含"#"

    发表评论

    最新留言

    感谢大佬
    [***.8.128.20]2025年04月24日 14时30分47秒