滚动到视图中时,菜单的屏幕外文本会出现延迟 - WebView 问题? (iOS)
我的 iOS 应用程序中有一个很大的向下钻取菜单。 菜单内容源自XML。 它存储在 SQLite 数据库中,并且正在使用 Webview。 为什么要使用Webview?因为文本有样式(字体大小/颜色)。
问题是这样的:当你向下滚动菜单时,之前在屏幕外的文本栏在 1/2 秒内保持不可见。他们需要一些时间来加载。当您再次向上滚动时,被移出屏幕的顶部项目现在也需要一些时间才能显示。
使用 WebView 时有没有办法提高性能?有没有办法消除这种视觉加载时间?我们应该考虑哪些方法?感谢您的任何帮助。
I have a large drilldown menu in my iOS app.
The menu content originated from XML.
It's stored in an SQLite database and Webview is being to used.
Why is Webview being used? Because the text has styling (font size/ color).
Here's the problem: When you scroll down the menu, the text bars that were previously offscreen remain invisible for a 1/2 second. They're taking awhile to load. And you scroll up again, the top items that were moved off screen now take time to appear as well.
Is there a way to improve this performance when working with WebView? Is there anyway to eliminate this visual loading time? Are there approaches we should consider? Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否将 Web 视图放入
UITableView
中?你真的不能这么做;他们会互相争斗(这被明确记录为不支持)。主要有两种解决方案:将这部分程序重新设计为Web应用程序,或者使用Core Text进行布局。在单个
UIWebView
中完成所有工作要快得多,但需要在 JavaScript 和 Objective-C 之间移动,这很难开发和调试。如果您采用这种方式,我通常建议您将 JavaScript 部分构建为“迷你应用程序”,您可以在 Safari 中开发和调试,然后插入。对于简单的布局,Core Text 并不太难。如果您创建一个
CFAttributedString
,那么您需要绘制一个非常简单的框架:以及所需的插件: 是的,我的书将包含 20 多页各种花哨的文本布局,大部分使用 Core Text (今天刚刚完成该章)。但对于简单的东西来说,只要不需要剪切和粘贴,上面的内容就足够了。
Are you putting web views inside of a
UITableView
? You really can't do that; they'll fight each other (and this is explicitly documented as not supported).There are two main solutions: redesign this part of the program as a web app, or layout with Core Text. Doing all the work in a single
UIWebView
is much faster, but requires moving between JavaScript and Objective-C which is difficult to develop and debug. If you go this way, I generally recommend that you build the JavaScript part as a "mini-app" that you can develop and debug in Safari, and then drop-in.For simple layout, Core Text isn't too hard. If you create a
CFAttributedString
, here's all you need to draw a very simple frame:And the required plug: Yes, my book will include over 20 pages on all kinds of fancy text layout, mostly using Core Text (just finishing that chapter today). But for the simple stuff the above is enough, as long as you don't need cut and paste.