【发布时间】:2011-08-31 14:36:47
【问题描述】:
在 UITextView 中,我可以将控件的高度调整为它的内容,如下所示:
CGRect frame = textView.frame;
frame.size.height = textView.contentSize.height;
textView.frame = frame;
但我想改用 UIWebView 来显示富文本。 UIWebVie 的内容是:
NSString *myDescriptionHTML = [NSString stringWithFormat:@"<html> \n"
"<head> \n"
"<style type=\"text/css\"> \n"
"body {font-family: \"%@\"; font-size: %@; }\n"
"</style> \n"
"</head> \n"
"<body>%@</body> \n"
"</html>", @"helvetica",
[NSNumber numberWithInt:12], @"yadayadayada..."];
[webView loadHTMLString:myDescriptionHTML baseURL:nil];
所以 UIWebView 只包含纯文本。我怎样才能达到类似于上面的 UITextView 代码的结果?
【问题讨论】:
标签: javascript iphone objective-c uiwebview