I'm using th开发者_C百科e following code it is working fine if I want to make a HTML page but it is not working on UIWebView
. it looks like don't know why web view is not rendering the HTML tags. Is there any way I can fix it?
NSString *htmlString = [NSString stringWithFormat:@"<html><head><style type='text/css'>body { color:#FFFFFF; background-color: #000000; }</style></head><body>%@</body></html>",string];
[webView loadHTMLString:htmlString baseURL:nil];
This code works for me:
- (void)viewDidLoad {
[super viewDidLoad];
NSString *string = [[NSString alloc] initWithFormat:@"Helooooooo"];
NSString *htmlString = [[NSString alloc] initWithFormat:@"<html><head><style type='text/css'>body { color:#FFFFFF; background-color: #000000; }</style></head><body>%@</body></html>", string];
[webView loadHTMLString:htmlString baseURL:nil];
}
Here's a screenshot:
精彩评论