私は非常に難しい問題を抱えています。これが私のカスタムセルの外観です。
|--------------------------------------------------------------------------|
| |
| |
| 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;
}
これが私が得た距離です。このテーブルビューを正しく埋める方法がわかりません。他のイメージ ビューは、img_Player2、img_Player3、img_Player4、img_Player5 という名前です。
誰でも助けることができますか?
ありがとうございました
私が達成したいことを画面に表示
これは私が達成したいことです:
そして、現時点ではこれを持っています。