【发布时间】:2010-11-16 19:13:26
【问题描述】:
我在 UITableViewCells 中有一些 UISwitches。但是,此表由多个部分组成。向下滚动表格时,有时会使用不属于下划线部分的无效开关更新新创建的单元格。交换开关的顺序不是不可预测的,它只是随机地将开关添加到单元中。然而这是一个奇怪的情况。
这就是我所做的。
if(indexPath.section == 1){
switch (indexPath.row) {
case 0:
cell.textLabel.text = @"Text 1";
switch1 = [[UISwitch alloc] initWithFrame:CGRectZero];
cell.accessoryView = switch1;
[cell.contentView addSubview :switch1];
break;
case 1:
cell.textLabel.text = @"Text 2";
switch2 = [[UISwitch alloc] initWithFrame:CGRectZero];
cell.accessoryView = switch2;
[cell.contentView addSubview :switch2];
break;
case 2:
........
More sections
......
那么这可能是什么问题?
谢谢。
【问题讨论】:
-
你明白了吗?
标签: iphone cocoa-touch uitableview iphone-sdk-3.0 ios4