gpt4 book ai didi

iphone - 在滑动时更改单元格的背景颜色以删除

转载 作者:行者123 更新时间:2023-12-01 18:18:46 24 4
gpt4 key购买 nike

当用户滑动它以获取删除按钮时,是否可以更改单元格的背景颜色。我已经搜索了很多,但没有得到任何解决方案。

提前谢谢。

最佳答案

这将帮助您:

- (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.backgroundColor = [UIColor redColor];
}

根据官方文档 here , 这个 UITableViewDelegate方法是为这类工作量身定做的。

In this "swipe to delete" mode the table view does not display any insertion, deletion, and reordering controls. This method gives the delegate an opportunity to adjust the application's user interface to editing mode.



编辑 ::根据你想要捕捉用户不删除单元格但滑动结束编辑模式的事件的评论。为此,我们有以下代表:
- (void)tableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.backgroundColor = originalColor;
}

关于iphone - 在滑动时更改单元格的背景颜色以删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18958883/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com