ios - viewForHeaderInSection 没有在 reloadData 上被调用
问题描述
viewForHeaderInSection 没有在 reloadData 上被调用。加载视图时如何第一次调用它。很奇怪。有什么帮助吗?我已经实现了以下委托方法。
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 0;
}
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section
{
return 1500.0f;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return UITableViewAutomaticDimension;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {}
解决方案
您heightForHeaderInSection
可能会0
因为UITableViewAutomaticDimension
不起作用而返回。为了UITableViewAutomaticDimension
工作,您必须设置所有相对于单元格容器视图的左侧、右侧、底部和顶部约束。
推荐阅读
- python - Python ARP 扫描器
- c++ - const 引用的内存位置
- r - ggplot2 错误:需要 TRUE/FALSE 的地方缺少值。我不知道
- c - 如何在C中使用大于和小于(>和<)比较浮点数
- c# - 使用 null 属性查询 DefaultIfEmpty 的性能
- variables - GNU Make:为什么调用函数不能用于简单的扩展变量?$1 未展开
- java - 有没有办法在 Kotlin 协程范围内启动可运行文件?
- android - Android Studio中的“dp”和int有什么关系?
- angular - 使用无效数据调用 Query.startAt()。不支持的字段值:自定义对象
- c++ - 在 C++ 中编辑注册表项