gpt4 book ai didi

ios - 如何删除 UITableView 中的空单元格?

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

我正在尝试显示一个简单的 UITableView一些数据。我希望设置 UITableView 的静态高度这样它就不会在表格末尾显示空单元格。我该怎么做?

代码:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
NSLog(@"%d", [arr count]);
return [arr count];
}

最佳答案

设置零高度表页脚 View (可能在您的 viewDidLoad 方法中),如下所示:

swift :

tableView.tableFooterView = UIView()

Objective-C:

tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];

因为表格认为需要显示页脚,所以除了您明确要求的单元格之外,它不会显示任何单元格。

界面构建器专业提示:

如果您使用的是xib/Storyboard,则只需将 UIView(高度为 0pt)拖到 UITableView 的底部即可。

关于ios - 如何删除 UITableView 中的空单元格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38781514/

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