开发者

Unable to change colour in UIWebView

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:

Unable to change colour in UIWebView

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜