【发布时间】:2023-03-11 12:35:01
【问题描述】:
我在 Stack Overflow 上寻找解决方案,但没有找到。我的代码是:
CGRect rect = _postContentView.bounds;
_postContentUIWV = [[UIWebView alloc] initWithFrame:rect];
[_postContentUIWV loadHTMLString:selectedPostCD.content baseURL:nil];
int fontSize = 30;
NSString *jsString = [[NSString alloc] initWithFormat:
@"document.getElementsByTagName('span')[0].style.webkitTextSizeAdjust='%d%%'",
fontSize];
[_postContentUIWV stringByEvaluatingJavaScriptFromString:jsString];
[_postContentView addSubview:_postContentUIWV];
还有UIWebView里面的HTML部分:
<p style="text-align: justify;">
<span style="line-height: 1.5em;">blablablablablabla</span>
</p>
我的代码不会增加UIWebView 内的字体大小。我该如何解决?
【问题讨论】:
-
你把你的代码放在哪里了?是在
webViewDidFinishLoadUIWebView 委托方法中吗? -
它在 - (void)viewDidLoad