为什么drawRect在自定义UITableViewCell中为大图像滚动比UIImageView慢 [英] Why does drawRect scroll slower than UIImageView for large images in custom UITableViewCell

查看:146
本文介绍了为什么drawRect在自定义UITableViewCell中为大图像滚动比UIImageView慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的UITableViewCell模型,完全来自这里找到的自定义UITableViewCell教程 -
http://developer.apple.com/library/ios/#samplecode/AdvancedTableViewCells/Introduction/Intro.html#//apple_ref/doc/uid / DTS40009111

I have a custom UITableViewCell modelled exactly from the custom UITableViewCell tutorials found here - http://developer.apple.com/library/ios/#samplecode/AdvancedTableViewCells/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009111

此处 -
http://developer.apple.com/library/ios/#samplecode/TableViewSuite/Introduction/Intro.html#/ / apple_ref / doc / uid / DTS40007318

使用drawRect渲染所有内容,绘制3个字符串和1个图像时滚动速度为55 FPS。图像是通过 -

Everything is rendered using drawRect and the scrolling speed is 55 FPS when drawing 3 strings and 1 image. The image is drawn via -

[self.sampleImage drawInRect:CGRectMake(0, 0, 55, 55)];

奇怪的是,当我渲染相同的图像但是在更大的区域时,滚动速度降低到25 FPS

Oddly enough, the scrolling speed reduces to 25 FPS when I render the same image but in a bigger area

[self.sampleImage drawInRect:CGRectMake(0, 0, 320, 80)];

我在Apple的示例代码中使用drawRect中的更大图像进行了实验,确保帧速率降至25 FPS 。

I experimented with bigger images in drawRect in Apple's sample code and sure enough the frame rate drops to 25 FPS.

当我绘制字符串并通过UIImageVew显示图像时,FPS会回升到55。


  • 如何在UITableViewCell中使用drawRect绘制大图像,同时保持50 FPS的滚动速度?

  • How can large images be drawn using drawRect in a UITableViewCell while maintaining 50 FPS scrolling speed?

UIImageView能否比在drawRect中绘制图像更快(对于UITableViewCell)?

Can UIImageView ever be faster than drawing an image in drawRect (for a UITableViewCell) ?

是否有任何GPU与CPU的力量在起作用?

Are there any GPU vs CPU forces at play?

推荐答案

@darcwader非常注重。我认为所有示例使用drawRect的原因是因为它最初(设置单元格)更昂贵,但之后动画它们要便宜得多。然而,对于大图像来说,绘制它们的成本要高得多,如果你滚动过多个图像,那么使用drawRect的好处就不会实现。

@darcwader has it pretty much spot on. I think the reason why all the examples use drawRect is because it's more expensive initially (to set up the cells) but afterwards its much cheaper to animate them. For large images however it's going to be significantly more costly to draw them up and if you're scrolling past multiple ones the benefits of using drawRect aren't realized.

这篇关于为什么drawRect在自定义UITableViewCell中为大图像滚动比UIImageView慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆