在我的应用程序中,我从服务器获取图像,并能够在ImageView中显示这些图像。但现在我想将从服务器获取的图像存储在TableView中,并在单击TableView单元格时显示它们。我希望如何制作图像缩略图以便在TableView单元格中显示。如果我直接在TableView单元格中显示图像,它会显得有些笨拙。为此,我想制作该图像的缩略图并在TableView单元格中显示它......请问有人可以帮助我如何通过编程方式创建图像缩略图吗?
- (void) createThumbView { float y_axis = Set y axis;
int x = 0;
int totalImgs = total images;
int tempCnt = 0;
for (int i = 0; i < totalImgs;)
{
float x_axis = set x axis;
int loopCount = 0;
if (totalImgs - tempCnt >= (no of images in row))
{
loopCount = (no of images in row);
}
else
{
loopCount = totalImgs % (no of images in row);
}
for (int j = 0; j < loopCount; j++)
{
MasksData *mData = [masksList objectAtIndex:x];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(x_axis, y_axis, width, height);
[btn setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@.png",mData.bgImage]] forState:UIControlStateNormal];
btn.backgroundColor = [UIColor clearColor];
btn.tag = x;
[scroll View addSubview:btn];
//photoCount++;
x_axis += width + some space;
tempCnt++;
i++;
x++;
}
y_axis += height + some space;
scroll View.contentSize = CGSizeMake(320.0, y_axis);
}