1
다음 코드는 이미지를 맨 위 섹션/셀에 넣은 다음 다른 이미지를 넣어야합니다. 문제는 코드가 화면을 벗어날 때 셀을 재사용하려고하지만 코드를 바꾸어야한다는 것입니다.이미지와 셀을 교체하지 않고 UITableView를 다시 그립니다.
http://screencast.com/t/OoQWMI5zCKVc
코드는 다음과 같다 : 텍스트를 표시됩니다 UITableViewCell
의 새로운 인스턴스를 만들 때
-(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;
}
}
+1 나를 때려 눕힌다. – Benjie
너는 beut! 고마워, 너무 오랫동안 보았다 – TMB87
하하 문제 없어, 때로는 신선한 눈 쌍이 필요해. –