gpt4 book ai didi

ios - UITableViewCell EditingStyle Delete自动取消选择tableview中的所有可见单元格

转载 作者:行者123 更新时间:2023-11-29 01:01:15 25 4
gpt4 key购买 nike

我使用一个分组的 UITableView 和实现的 commitEditingStyle 从表中删除一行。 (在我的 UIViewController 中,没有 UITableViewController)。我还使用带有选中图像的自定义单元格。要更改图像,我只需使用它:

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];

// Configure the view for the selected state
if (selected) {
self.img_checked.image = [UIImage imageNamed:@"checked.png"];

else {
self.img_checked.image = [UIImage imageNamed:@"unchecked.png"];
}
}

我的问题是,当滑动一行时会根据需要出现“删除”,但它会自动取消选择表格 View 中的所有可见单元格

如何防止 tableview 这样做?

最佳答案

您应该保存选定状态的索引或索引路径,然后在 cellForRow 或 willDisplayCell: delegates 中检查它。您可以通过字典或数组来制作它。第二种方法是将它保存在您在单元格中设置的对象内的单独变量中(如果您这样做的话)。

关于ios - UITableViewCell EditingStyle Delete自动取消选择tableview中的所有可见单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36960324/

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