ios - 分组的 UITableView 35 点/像素顶部插图/填充

标签 ios objective-c uitableview

请注意,我将在这个问题中将点称为像素。

我有一个包含 3 个部分的分组 UITableView,每个部分都有一个 40 像素高的标题 View 。表格 View 中的第一个标题似乎被系统赋予了 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];

最佳答案

似乎是这样的:

[self setTableHeaderView:[[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, width, FLT_MIN)]];

在 init 中,self 是一个 UITableView,将去掉前 35 个点。

关于ios - 分组的 UITableView 35 点/像素顶部插图/填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23663947/

相关文章:

ios - 使用 UIImagePickerController 获取视频

objective-c - NSStrings 之前的 '@' 实际上是重载运算符吗?

ODF 和 ODS (OpenOffice) 的 Objective-C 包装器?

ios - TableView 或 TableView 单元格宽度不正确

javascript - 在一个查询中检索一行的两个值

iOS 如何比较对象是否相等?

ios - CoreBluetooth 在 iPad 上检测到某些设备时崩溃

ios - 在 iOS 中同时切换 Controller 和 View

objective-c - iPad On Disk Encryption 是否只影响一个应用程序或整个系统

iphone - 在 iPhone VOIP 应用程序中保持 SIP 注册的时间间隔小于 600 秒