如何强制 UIWebView 在屏幕外时更新?
我有一个 UIWebView,我将其设置为一些文本并显示,然后隐藏,更改文本,然后再次显示。我遇到的问题是,当我再次使视图可见时,我会立即看到旧文本。有没有办法强制 UIWebView 在显示时显示新文本?
代码排序正确,如下所示:
[back assignLabelText:[facts getCurrentFact].answer];
[self doAnimation:back.view andViewToHide:front.view flipRight:YES];
I have a UIWebView that I'm setting to some text and displaying and then hiding, changing the text, and displaying again. The issue I'm running in to is that when I make the view visible again I see the old text for an instant. Is there a way to force the UIWebView to show the new text when it displays?
The code is ordered correctly and looks like this:
[back assignLabelText:[facts getCurrentFact].answer];
[self doAnimation:back.view andViewToHide:front.view flipRight:YES];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该至少等到 WebView 的
webViewDidFinishLoad:
被触发后再显示 WebView。即使如此,也可能会出现一些延迟,因此我在显示视图之前添加了额外的 0.1 秒延迟。You should wait until at least the webview's
webViewDidFinishLoad:
is fired before revealing the webview. Even then there can be some lag, so I add an additional 0.1 second delay before revealing the view.调用 setNeedsDisplay 在背面视图上
Call setNeedsDisplay on back's view
我创建了一些新函数来执行动画,并使用 0.1 的延迟通过
performSelector
运行它们。这感觉像是一个 hack,但它确实有效,并且它解决了我在 UILabels 中遇到的相同问题,即文本发生了变化。
I made some new functions to do my animations and used a delay of 0.1 to run them via
performSelector
.It feels like a hack but it works and it takes care of the same issues I was having with UILabels that have their text change.