Iphone 如何在一个可用的单元格中高效地显示图像

Iphone 如何在一个可用的单元格中高效地显示图像,iphone,objective-c,xcode,Iphone,Objective C,Xcode,目前我有两种在单元格中显示图像的方式,哪种方式有助于表格的平稳运行,稍后我将使用lazytable?在每个单元格中,按钮应该被赋予一个设置图像,还是添加一个具有设置图像的imageview同样好?同样在第一种方法中,我必须动态缩放每个图像。谢谢大家! UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; UIImage *img = [UIImage imageWithData:"png image from url"

目前我有两种在单元格中显示图像的方式,哪种方式有助于表格的平稳运行,稍后我将使用lazytable?在每个单元格中,按钮应该被赋予一个设置图像,还是添加一个具有设置图像的imageview同样好?同样在第一种方法中,我必须动态缩放每个图像。谢谢大家!

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

UIImage *img = [UIImage imageWithData:"png image from url"];

[button setImage:img forState:UIControlStateNormal];


/// Or


UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

UIImage *img = [UIImage imageWithData:"png image from url"];

UIImageView *imageView2 = [[UIImageView alloc] initWithImage:img];

[button2 addSubview:imageView2];

既然按钮有图像属性,为什么要向按钮添加图像视图,建议使用方法1

我这样做是因为我不必重新缩放图像。对于setimage,我必须先将其调整到一定的宽度和高度,但我想这没关系,谢谢