gpt4 book ai didi

ios - 在 UITableView 中将 x 位置设置为 UITablecell

转载 作者:行者123 更新时间:2023-12-01 16:48:37 26 4
gpt4 key购买 nike

我有 UITableview因为我要加载自定义表格单元格。默认单元格坐标在零位置,但我需要将它放在我需要的位置(即 30,0)
我写了这样的代码::

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{

NSLog(@"tableView willDisplayCell");
CGRect frame = cell.frame;
frame.origin.x = 30;
frame.size.width = 250;
cell.frame = frame;
}

第一次表格单元格
重新加载后没有在提到的位置加载它工作正常提前谢谢

最佳答案

不要更改单元格的框架。相反,将单元格背景设置为您的整体背景颜色(可能是透明的),并将所需大小的 View 添加为单元格的 subview contentView .然后将所有内容添加到此 View 。

关于ios - 在 UITableView 中将 x 位置设置为 UITablecell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18030537/

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