在编辑模式下更改UITableViewCells的背景

问题描述:

当向左滑动删除(在我的情况下为void)一行时,黑色表格视图出现白色时出现问题。在编辑模式下更改UITableViewCells的背景

我试着从ViewController一直到TableViewCell的内容的每一步,设置颜色的每一个可能的参数。

我设法得到它深灰为“选择”与CellForRowAtIndex如下:

UIView *bgColorView = [[UIView alloc] init]; 
    bgColorView.backgroundColor = [UIColor darkGrayColor]; 
    [cell setSelectedBackgroundView:bgColorView]; 

所以我想解决的办法是类似的东西。

我在iPhone上有一个类似的设置,其中TableView是在一个TableViewController中没有发生问题。在这种特殊情况下,TableView是在一个常规的ViewController中。

附上截图。请指教。编辑:请注意,空格不是出现在无效按钮旁边的按钮。它是根据您拖动单元格的距离改变大小的空白空间。如果释放细胞,白色空间会完全消失,但反弹会显示白色空间。

刷卡左(在运动):

enter image description here

刷卡左(释放):

enter image description here

Unswiped:

enter image description here

+0

您可以提供一个完整的单元格屏幕快照,并且不显示删除选项。同时也发布你的代码,以便查找问题。 – nikhil84 2014-09-10 11:27:06

+0

你想要什么代码部分?除了CanEditRowForIndex允许使用CanEditRowForIndex之外,实际刷卡中没有涉及代码,它只是为我的表返回true。未添加另一个屏幕截图。 – nickdnk 2014-09-10 11:51:37

哇 - 原来我只需要实现以下方法:

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { 

    cell.backgroundColor = [UIColor blackColor]; 

} 

讽刺的是我搜索高和低的解决方案,才发现的15分钟我问后。几个星期以来一直困扰着我。

啊,好吧,也许有人在这个问题上绊倒了。