解决 Json 中 Html 内容因为反编译带有"\"导致 WebView 无法直接加载问题(字符串的查找与替换)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决 Json 中 Html 内容因为反编译带有"\"导致 WebView 无法直接加载问题(字符串的查找与替换)相关的知识,希望对你有一定的参考价值。

NSString *path = [[NSBundle mainBundle] pathForResource:@"ad_type = 4" ofType:@"html"];
    NSString *htmlStr = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
    if (htmlStr != nil && [htmlStr rangeOfString:@"\\"].location != NSNotFound) {
        htmlStr = [htmlStr stringByReplacingOccurrencesOfString:@"\\" withString:@""];
    }

    UIWebView *web = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
    [web loadHTMLString:htmlStr baseURL:nil];
    [self.view addSubview:web];

 

以上是关于解决 Json 中 Html 内容因为反编译带有"\"导致 WebView 无法直接加载问题(字符串的查找与替换)的主要内容,如果未能解决你的问题,请参考以下文章