【发布时间】:2010-12-23 18:16:07
【问题描述】:
我正在使用表格视图来显示列表。只有一个单元格有UITableViewCellStyleValue1。问题是向上/向下滚动时,详细的文本显示不好。这是代码。
有人可以帮我吗?
【问题讨论】:
我正在使用表格视图来显示列表。只有一个单元格有UITableViewCellStyleValue1。问题是向上/向下滚动时,详细的文本显示不好。这是代码。
有人可以帮我吗?
【问题讨论】:
您没有正确处理单元格重用。尝试这样做,我认为您应该能够看到我在做什么不同。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
if(indexPath.row == 0)
{
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier2] autorelease];
}
cell.textLabel.textColor = [UIColor whiteColor];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.detailTextLabel.textColor = [UIColor yellowColor];
cell.detailTextLabel.text = @"Description";
}
else
{
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.textColor = [UIColor whiteColor];
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
// Configure the cell.
cell.textLabel.text = [radioList objectAtIndex:indexPath.row];
return cell;
}
【讨论】: