gpt4 book ai didi

ios - 自定义表格单元格 : Why delete icon appears on the content of the cell view?

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

我的表格 View 中有自定义单元格。 当合适的 View 处于编辑模式时。圆形删除图标出现在单元格的内容上。

如何将内容向右移动以便为那个红色的小圆按钮腾出位置。

在自定义单元格 View 中,layoutsubview 应该发生一些事情。 我应该调整单元格 View 的哪个 subview 的大小?

提前致谢

请看看我现在的代码

- (void) layoutSubviews
{
[super layoutSubviews];

CGFloat width = self.width - _productImage.right - 20.f;

if (self.accessoryView)
{
width -= self.accessoryView.width;
}

_productName.width = width;
_productDescription.width = width;
_productPrice.width = width;

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:3.0f];

for (UIView *subview in self.subviews) {


if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {
CGRect newFrame = self.contentView.frame;
self.contentView.frame = CGRectMake(40, self.contentView.frame.origin.y, newFrame.size.width, newFrame.size.height);
}
else if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellEditControl"]) {
CGRect newFrame = self.contentView.frame;
self.contentView.frame = CGRectMake(40, self.contentView.frame.origin.y, newFrame.size.width, newFrame.size.height);
}
else if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellReorderControl"]) {
CGRect newFrame = self.contentView.frame;
self.contentView.frame = CGRectMake(40, self.contentView.frame.origin.y, newFrame.size.width, newFrame.size.height);
}
}
[UIView commitAnimations];

最佳答案

您可以查看 tableview.isEditing 属性。

如果,则将 cell.contentView 框架更新为x-difference,否则使用默认值。

希望这就是您所需要的。

享受编码:)

关于ios - 自定义表格单元格 : Why delete icon appears on the content of the cell view?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11862751/

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