gpt4 book ai didi

ios - 在 ios 7 中启用编辑时,UITableViewCell subview 不移动

转载 作者:行者123 更新时间:2023-11-28 22:22:52 25 4
gpt4 key购买 nike

我有一个带有 UITableViewCell 自定义类的 TableView ,我已经为每个 UITableViewCell 添加了一些 subview ,现在当我启用这样的编辑时

[tableView_ setEditing:YES animated:YES];

一个红色的删除按钮出现在每个单元格的左侧,每个单元格都向右移动,除了添加到单元格上的 subview 。这会导致按钮出现在 subview 的顶部。如何解决这个问题?谢谢

最佳答案

UITableViewCell 有一个针对其内容的特定 View ,cell.contentView,确保您所有的 addSubview 调用都是针对此 View 而不是单元格。例如:

// good
UILabel* label = [[UILabel alloc] init];
[cell.contentView addSubView:label];

// bad
[cell addSubView:label];

关于ios - 在 ios 7 中启用编辑时,UITableViewCell subview 不移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19839792/

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