【发布时间】:2012-10-09 19:15:44
【问题描述】:
我有一个非常棘手的问题。这就是我的自定义单元格的样子。
|--------------------------------------------------------------------------|
| |
| |
| Imageview1 Imageview2 Imageview3 Imageview4 imageview5 |
| |
| |
| |
|--------------------------------------------------------------------------|
我有一个包含 20 张图像的核心数据库。我想做的是用我的图像填充所有这些图像视图。因此,我应该有 5 行,每个图像视图中都有不同的图像。
这是我的 cellforrowAtIndexpath 的代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
for(int i=0;i<5;i++)
{
float xCoord = 0.0;
Team *team = [self.fetchedResultsController objectAtIndexPath:indexPath];
NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:team.image]];
UIImage* image = [[UIImage alloc] initWithData:imageData];
UIImageView* imgView = [[UIImageView alloc] initWithImage:image];
[imgView setFrame:CGRectMake(xCoord,0,imgView.frame.size.width, imgView.frame.size.height)];
[cell.contentView addSubview:imgView];
xCoord += imgView.frame.size.width;
}
return cell;
}
这是我走了多远。我现在不知道如何正确填写这个 tableview。其他的 imageview 名称为 img_Player2,img_Player3,img_Player4,img_Player5。
有人可以帮忙吗?
谢谢
显示我想要实现的目标
This是我想要实现的:
目前我有this。
【问题讨论】:
标签: objective-c ios ipad uitableview core-data