我在每个 tableview 单元格上都有一个 UISwitchView,并希望允许对单元格进行重新排序。问题是当我在表格视图上设置 setEditing=true 时,附件(switchview)消失了。有没有办法同时保留?
编辑
static NSString *CellIdentifier = @"Edit Sources Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
NSUInteger row = [indexPath row];
Source *source = [self.sources objectAtIndex:row];
cell.textLabel.text = source.name;
UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero];
switchView.tag = row;
cell.accessoryView = switchView;
[switchView setOn:source.switchedOn animated:NO];
[switchView addTarget:self action:@selector(switchChangedForSource:) forControlEvents: UIControlEventValueChanged] ;