gpt4 book ai didi

ios - iPhone UITableView 在重用 UITableViewCell 时按下删除按钮后缺少披露按钮

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:24:32 26 4
gpt4 key购买 nike

我有一个 iPhone UITableView 显示自定义 UITableViewCell,在其右侧显示披露按钮图标。
当我滑动单元格时,披露按钮会自动替换为红色的“删除”按钮。如果我按下“删除”按钮,该行将从表格中删除,但随后会发生一些奇怪的事情。
当我滚动表格并且删除的单元格被重新使用时,数据被正确加载但披露按钮丢失

我尝试在 prepareForReuse 方法中重置按钮,但没有成功。

我不明白我错过了什么,因为行为似乎与邮件应用程序相同,因此 iPhone 操作系统应该原生支持它。

顺便说一句:UITableViewCell 是从 NIB 加载的。

最佳答案

看来我已经通过添加解决了问题

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

这行代码:

[cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];

我认为这条线对正常细胞没有用,但在删除后重新使用的细胞恢复正确的细胞行为......

无论如何删除我用过的行

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 

这个(我猜)标准行:

 [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];

谢谢斯特凡诺

关于ios - iPhone UITableView 在重用 UITableViewCell 时按下删除按钮后缺少披露按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/767482/

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