嗨朋友我的项目是基于解析来自JSON
的数据,我在解析数据方面做得很好,现在我的问题是。 In one of my module i received some html data from json. Now i need to display in screen by running that html.
是否有可能在ios中有可能请帮助我如何做到这一点。我不知道这个
这是我收到的JSON文件
但它不起作用。我需要运行那个html并且必须在textview中进行diaplay请帮助我如何做到这一点 提前致谢
答案 0 :(得分:3)
您获得的内容是HTML,因此使用UIWebView而不是UITextView,然后使用loadHTMLString。
///load
//tweet = [[NSDictionary alloc]init]; uneeded
id tweet = [NSJSONSerialization JSONObjectWithData:webData options:kNilOptions error:nil];
id items = tweet[@"aboutUsContent"];
//get html
NSMutableString *html = [NSMutableString string];
for(NSDictionary *item in items) {//it is just one item in your example but ill write the code so it does handle N items
id desc1 = [item valueForKey:@"content"];
[html appendString:desc1];
}
//now set it
[AboutWebView loadHTMLString:str baseURL:nil];
答案 1 :(得分:1)
您可以将数据导入NSSTRING并按以下方式加载:
[webView loadHTMLString:htmlString baseURL:nil];