1

i am getting a "text" from mysql database using web api and Json data i show the text in a uiwebview to ba able to use the links and show image, but the image are not showning:

this text is a snippet of the json text :

 <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>

and i do this in object 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];

but it looks like this:

enter image description here

enter image description here

iv been trying for days on google and trying different things but can make it work.

it looks like uiwebview user the alt tag instead og src ..... any one know how to fix that

htlmstring:

enter image description here

Skovie
  • 197
  • 3
  • 18

0 Answers0