У меня есть следующий код, который должен поместить изображение в верхний раздел / ячейку, а затем текст в других.Я думаю, проблема в том, что код пытается повторно использовать ячейку, когда она исчезает с экрана, но я не могу понять, что мне следует изменить.Вы можете посмотреть видео проблемы здесь:
http://screencast.com/t/OoQWMI5zCKVc
Код выглядит следующим образом:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifierText = @"TextCell";
static NSString *CellIdentifierImage = @"ImageCell";
if (indexPath.section == 0)
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierImage];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifierImage] autorelease];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,180)];
imageView.tag = 1;
imageView.image = [UIImage imageNamed:@"prem.jpg"];
[cell addSubview:imageView];
[imageView release];
}
return cell;
}
else {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierText];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifierImage] autorelease];
}
if(indexPath.section == 1)
cell.textLabel.text = [arryTableData objectAtIndex:indexPath.row];
else if(indexPath.section ==2)
cell.textLabel.text = [arryAddressInfo objectAtIndex:indexPath.row];
else if(indexPath.section == 3)
cell.textLabel.text = [arryTableActions objectAtIndex:indexPath.row];
else if(indexPath.section == 4)
cell.textLabel.text = @"REPLACE ME WITH ICONS";
return cell;
}
}