我想取代单元格的默认编辑模式行为。UITableViewCell自定义编辑视图
我不想要红色的圆线与线左辅助视图出现。
一旦进入编辑模式,我需要它将内容视图左移&显示我的删除按钮。
我有什么到目前为止(自定义的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会被重置。回到第一张图片。编辑标志不会保留我的contentview框架更改。
我已经加入这一行:
[cell setEditing:_tableView.isEditing animated:NO];
中的cellForRowAtIndexPath &
虽然它调用&设置编辑模式正确我的内容查看仍然在原来的位置&不更新
短的YouTube视频说明问题: Youtube link
其他人有这个问题吗?
您应该只为制作YouTube视频+1。现在很容易理解。 –