gpt4 book ai didi

ios - ios应用程序具有不同背景图像的自定义tableview单元格

转载 作者:行者123 更新时间:2023-12-01 17:23:01 25 4
gpt4 key购买 nike

我想设计一个tableview,以便每个单元根据条件具有不同的背景图像。单元格背景有10张图像,我想加载它们,以便在单元格上重复图像图案。例如,单元1-10分别拍摄1-10的图像。然后单元格11-20也拍摄图像1-10,依此类推。我该如何实现?

最佳答案

给出图像名称,例如:images_1 / 2 ... / 10.png

 //write it

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell1";

CustomCell *Cell = (CustomCell *)[tabeleYourTurn dequeueReusableCellWithIdentifier:CellIdentifier];
if (Cell == nil)
{
NSArray *topLevelObject= [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
}

for (id currentobject in topLevelObject)
{
if ([currentobject isKindOfClass:[UITableViewCell class]])
{
Cell = (CustomCell *) currentobject;

break;
}
}
}

NSString *image = [NSString stringWithFormat:@"images_%d.png", indexPath.row % 10 + 1];
Cell.imageView.image = [UIImage imageNamed:image];

return Cell;

}

可能会起作用。

关于ios - ios应用程序具有不同背景图像的自定义tableview单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19510700/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com