我正在尝试替换单元格的默认编辑模式行为.
我不想要左边的配件视图的红色圆圈出现.
我到目前为止(定制UITableViewCell)覆盖:
-(void) setEditing:(BOOL)editing animated:(BOOL)animated { /* don't call super */ // [super setEditing:editing animated:animated]; _isEditing = editing; CGFloat newContentViewX = 0.0f; UIColor *newDeleteButtonColor = [UIColor clearColor]; if ( _isEditing ) { newContentViewX = -40.0f; newDeleteButtonColor = [UIColor redColor]; } if ( animated ) { [UIView animateWithDuration:0.5f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^ { self.contentView.x = newContentViewX; //change frame.origin.x _deleteButton.backgroundColor = newDeleteButtonColor; } completion:nil]; } else { self.contentView.x = newContentViewX; //change frame.origin.x _deleteButton.backgroundColor = newDeleteButtonColor; } } -(BOOL) editing { return _isEditing; }
&安培;这是结果:
以上代码非常好!直到开始滚动& contentview被重置.回到第一个图像.编辑标志不会持久化我的内容视图框架更改.
我已经添加了这一行:
[cell setEditing:_tableView.isEditing animated:NO];
在cellForRowAtIndexPath&虽然它正在呼叫&正确设置编辑模式我的内容视图仍然处于原始位置&没有更新
短视频解说问题:
Youtube link
有人有这个问题吗?