如何加速和使 iPhone 中的单元格平滑滚动?
我使用 UIView 和 UITableViewController 做了一个文本渲染程序。我所做的是在使用drawRect方法之前,我只是计算所有单元格的高度以及每个文本的开始和结束。高度,宽度。这样,我可以近似估计单元高度,然后绘制文本。
我为肖像和肖像都这样做了。横向模式。我的程序看起来像 Twitter 更新。当用户更改为横向模式时,我为横向模式计算了相同的结果。下次,我只需检索存储的用于绘制文本的数据(在应用程序退出之前有效)。
现在我的问题是,当我的投入较少时,它效果很好。但对于巨大的输入(例如 100 个输入),显示文本需要一些时间。另外,我的程序的滚动有些不流畅。我的应用程序中也没有泄漏。
请任何人建议我做这个应用程序的好方法,并使它如此顺利和更快......
提前致谢, 拉伊坎特
i did a text rendering program using UIView and UITableViewController. What i did is before going drawRect method, i just calculate all of the cells height as well as each text start & height,width. So that, i can estimate the cell height approximately and then i draw the text.
I did this for both portrait & landscape mode. My program looks like twitter updates. When the user changed to landscape mode i calculated the same things for landscape mode. Next time, i simply retrieve the stored data for drawing text(Valid before application quits).
Now my problem is, when my inputs are less, it works good. But for the huge input say 100 inputs, it takes some time to show the text. Also, my program's scrolling is somewhat not smooth. Also there is no leak in my application.
Please anyone suggest me the good way to do this application and make it so smooth and faster...
Thanks in Advance,
Rajkanth
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对此的简短回答是尽量减少在渲染单元格时进行的任何计算。这包括任何透明背景。为了实现最快的滚动,理想情况下您应该拥有很少量的非不透明元素。
The short answer to this is to minimize any computation you do in rendering of the cells. This includes any transparent backgrounds. To achieve the fastest scrolling, ideally you would have very few amounts of non-opaque elements.
诀窍是通过将所有单独的元素合并到一个视图中来仅拥有一个大的不透明元素。
http://blog.atebits.com/2008/ 12/快速滚动-tweetie-with-uitableview/
The trick is to only have one big opaque element by coalescing all your individual elements into a single view.
http://blog.atebits.com/2008/12/fast-scrolling-in-tweetie-with-uitableview/