0
我有一个自定义单元格的tableView,我的第一个单元格与其他单元格不同。 (它包含一个小图像和一个标签)。我做这样的:UITableView和自定义单元格
#
pragma mark - tableView data source methods
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
SuggestionCarteCell *cell = (SuggestionCarteCell *)[tableView dequeueReusableCellWithIdentifier:@"carteCell"];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SuggestionCarteCell" owner:nil options:nil] ;
cell = [nib objectAtIndex:0];
}
if (indexPath.row == 0) {
// crer l'image
NSLog(@" je suis dans row 0");
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(21, 9, 13, 26)];
imageView.image = [UIImage imageNamed:@"iconeLocation"];
[cell addSubview:imageView];
cell.labelRegion.frame = CGRectMake(21+13+10, cell.labelRegion.frame.origin.y,cell.labelRegion.frame.size.width , cell.labelRegion.frame.size.height);
cell.labelRegion.text = [NSString stringWithFormat:@"A proximité,"];
}
else{
Region *region = [Region new];
region =(Region *) [arrayRegion objectAtIndex:indexPath.row];
cell.labelRegion.text =region.nomRegion;
}
return cell;
}
在第一时间它的好
,但是当我滚动我的第一个单元格(小图片加)出现在其他行。我做错了什么?谢谢
我选择了第二个解决方案,两个自定义单元格。谢谢 – samir 2012-03-21 15:22:04