0

我正在使用以下方式从网站加载 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;

ETC

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

4

1 回答 1

0

试试这个,它对我有用

-(void)loadHTML{

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

}

于 2012-08-13T06:18:06.250 回答