图像未在UIWebview中加载

时间:2015-03-05 13:15:10

标签: ios json uiwebview

我正在收到#34;文字"从mysql数据库使用web api和Json数据我在uiwebview中显示文本,以便能够使用链接和显示图像,但图像没有显示:

此文本是json文本的片段:

 <p style=\"text-align: center;\"><img alt=\"\" src=\"http://sofabold.dk/images/blog/Placeringsaendring2014.jpg\" style=\"border-style:solid; border-width:2px; height:852px; width:321px\" /></p>

我在对象c中执行此操作:

        NSString *blogText =[NSString stringWithFormat:@"%@", [blogInfo mutableArrayValueForKey:@"indhold"]];

        NSLog(@"%@",blogText);

        NSString *newBlogText = [NSString stringWithFormat: @"%@",blogText];

        // Set op the text in webview.

        NSString *newBlogText1 = [newBlogText stringByReplacingOccurrencesOfString: @"\\n" withString: @""];

        NSString *newBlogText2 = [newBlogText1 stringByReplacingOccurrencesOfString:@"(" withString:@""];
        NSString *newBlogText3 = [newBlogText2 stringByReplacingOccurrencesOfString:@")" withString:@""];
        NSString *newBlogText4 = [newBlogText3 stringByReplacingOccurrencesOfString:@"\"" withString:@""];


        NSString *stripedAll = [newBlogText4 stringByReplacingOccurrencesOfString: @"</script>" withString: @"Dette kan desværre ikke ses på dette media, besøg venligst www.sofabold.dk"];


        // NSLog(@"%@",stripedAll);

        NSString *headLine = [NSString stringWithFormat:@"%@",[blogInfo mutableArrayValueForKey:@"subject"]];

        headLineString = [headLine decodeHTMLEntities ];


        NSString *cssString = [NSString stringWithFormat: @"<html><style type='text/css\'> body { background-color:transparent; font-family:Helvetica; color: #000000; font-size:14px;text-align:justify} .class1 { background-color:transparent; font-family:Helvetica-BoldOblique; color: #000000; font-size:18px;text-align:center }  </style> <body> <p class='class1'> %@ </p></body></html>",headLineString];




        NSString *htmlString = [NSString stringWithFormat:@"%@%@ <br /><br />%@ %@", cssString, stripedAll,_blogForfatter, _blogTime];

        [detailText loadHTMLString:htmlString baseURL:nil];

但它看起来像这样:

enter image description here

enter image description here

iv在谷歌上尝试了几天并尝试了不同的东西,但可以让它发挥作用。

看起来像uiwebview用户alt标签而不是og src .....任何人都知道如何解决这个问题

htlmstring:

enter image description here

0 个答案:

没有答案