OGeek|极客世界-中国程序员成长平台

标题: ios - 在编辑模式下更改 UITableViewCells 的背景 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 11:49
标题: ios - 在编辑模式下更改 UITableViewCells 的背景

当向左滑动以删除(在我的情况下为无效)一行时,黑色表格 View 显示为白色时遇到问题。

我尝试在从 ViewController 到 TableViewCell 的内容的每一步中设置所有可能的颜色参数。

我设法在 CellForRowAtIndex 中使用以下内容将其设为 darkGray:

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

所以我认为解决方案是这样的。

我在 iPhone 上进行了类似的设置,其中 TableView 位于不发生问题的 TableViewController 中。在这种特殊情况下,TableView 位于常规 ViewController 中。

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

向左滑动(运动中):

enter image description here

向左滑动(释放):

enter image description here

未刷卡:

enter image description here



Best Answer-推荐答案


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

-(void)tableViewUITableView *)tableView willDisplayCellUITableViewCell *)cell forRowAtIndexPathNSIndexPath *)indexPath {

    cell.backgroundColor = [UIColor blackColor];

}

具有讽刺意味的是,我到处寻找解决方案,但在我询问 15 分钟后才找到它。这已经困扰我好几个星期了。

啊,好吧,也许其他人偶然发现了这个问题。

关于ios - 在编辑模式下更改 UITableViewCells 的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25763861/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4