在UIWebview中没有加载Html

时间:2012-08-13 05:44:39

标签: iphone uiwebview

我正在使用以下方式从网站加载html

     -(void)connectionDidFinishLoading:(NSURLConnection *)connection{
//CategoriesParser *parser=[[CategoriesParser alloc]init];
//[parser setDelegate:self];
//[parser startParsing:xmlData];

NSString *str=@"<html><head></head><body>";

NSString* newStr = [[[NSString alloc] initWithData:urlData

                                          encoding:NSUTF8StringEncoding] autorelease];

 newStr=[NSString stringWithFormat:@"<html><head></head><body>%@</body></html>",newStr];


[webView loadHTMLString:newStr baseURL:nil];

}

但不幸的是它在webview上显示html代码

  <p style="text-align: justify;"><span style="font-family: helvetica; font-size: small;">The UAE manages what some Arab cities fail to achieve;

所以请通过在webview中加载html字符串来帮助我做错了。

1 个答案:

答案 0 :(得分:0)

试试这个,它对我有用

-(void)loadHTML{

NSMutableString *html  = [NSString stringWithFormat:@"<html><head></head><body>%@</body></html>",@"Hi"]; 
[self.tpWebView loadHTMLString:html baseURL:nil];

}