【发布时间】:2014-05-14 19:56:11
【问题描述】:
请注意,我将在这个问题中将点称为像素。
我有一个分组 UITableView 有 3 个部分,每个部分都有一个 40 像素高的标题视图。表格视图中的第一个标题似乎被系统赋予了 35 像素的 y 位置。
我尝试过使用 automaticallyAdjustsScrollViewInsets 和其他一些 iOS 7 自动部件,但无济于事。
为什么我的UITableView 内容被插入了 35 个像素?
编辑:我已经看到this answer 和许多其他线程。我有有效的标题和标题高度。此外,将默认值设置为 FLT_MIN、0.01f、1.0f 或 100.0f 并不能解决问题。
这是我的头文件实现:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
UIView *header = (self.headerViews.count > section ? self.headerViews[section] : nil);
return (header.viewHeight ? : FLT_MIN);
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *header = (self.headerViews.count > section ? self.headerViews[section] : nil);
return (header.viewHeight ? header : nil);
}
我也在设置:
- (BOOL)automaticallyAdjustsScrollViewInsets{return NO;}
和
[self setSectionHeaderHeight:FLT_MIN];
【问题讨论】:
-
为什么将点称为像素?如果你的意思是“点”,就说“点”。这种区别是有原因的。
-
你看过这个question吗?
-
@Michael 因为像素被更广泛地理解和搜索。
-
hmm,不了解区别的人无论如何都不应该尝试回答这个问题,恕我直言
-
你是否也使用了 heightForHeaderInSection 来设置合适的标题高度?
标签: ios objective-c uitableview