我已经实现了 LazyTableImage在我的示例项目中。我想在我的 1 个单元格中显示 3 个图像,你能告诉我我该怎么做吗?这是我的示例代码,下面给出我可以尝试这样做,但它没有在 1 个单元格中显示 3 个图像,我可以制作算法吗这在其他项目中工作正常但 LazyTableImage 它不工作请告诉我我该怎么做...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
static NSString *PlaceholderCellIdentifier = @"PlaceholderCell";
int nodeCount = [self.currentSelectedCategoryArray count]/4;
if (nodeCount == 0 && indexPath.row == 0)
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:PlaceholderCellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:PlaceholderCellIdentifier] autorelease];
cell.detailTextLabel.textAlignment = UITextAlignmentCenter;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
cell.detailTextLabel.text = @"Loading…";
return cell;
}
UITableViewCell *cell = [self.detailCatTable dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
int check = indexPath.row;
check = check*3;
for (int i = 0; i < 3; i++){
if(check+i < [self.currentSelectedCategoryArray count]){
if (nodeCount > 0)
{
// Set up the cell...
imageClass *imgC = [self.currentSelectedCategoryArray objectAtIndex:check+i];
cell.textLabel.text = imgC.imageName;
cell.detailTextLabel.text = imgC.imageID;
// Only load cached images; defer new downloads until scrolling ends
if (!imgC.cImage)
{
if (tableView.dragging == NO && tableView.decelerating == NO)
{
[self startImageDownload:imgC forIndexPath:indexPath];
}
// if a download is deferred or in progress, return a placeholder image
cell.imageView.image = [UIImage imageNamed:@"imageFrame.png"];
}
else
{
cell.imageView.image = imgC.cImage;
}
}
}
}
return cell;
}
最佳答案
cell
中只有 1 个 imageView
。您应该按照@alan duncan 的建议创建自定义UITableViewCell
。
在你的代码中你可以这样:
switch(i){
case 0:
((UIImageView*)[cell.contentView viewWithTag:1]).image = imgC.cImage;
break;
case 1:
((UIImageView*)[cell.contentView viewWithTag:2]).image = imgC.cImage;
break;
case 2:
((UIImageView*)[cell.contentView viewWithTag:3]).image = imgC.cImage;
break;
}
我希望你明白这一点。
关于objective-c - 如何在 1 个单元格中放置 3 个图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9639834/