我发现如果你将表格视图设置为编辑模式,在删除一行后滚动表格时,单元格编辑控件(左边的红色减号)处于随机状态(垂直或水平)滚动表格时的单元格.大概是因为我正在重复使用这样的单元格:
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
Run Code Online (Sandbox Code Playgroud)
如何强制编辑控件为每个单元格处于正确状态?它应始终处于默认的水平状态,除非我点击它以删除单元格.
编辑:这是单元格代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"WhateverIdentifier";
MyCell *cell = nil;
//This IF statement fixes the problem, but then I'm not reusing the cells
if (!tableView.isEditing) {
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
}
if (!cell) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"MyCell" owner:self options:nil] objectAtIndex:0];
}
//customize cell
return cell;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
750 次 |
| 最近记录: |