iOS 11 UiTableViewCell 位置问题

3

我有四个UITableView单元格,一个接一个地排列。在iOS 10.3上,第一个单元格紧贴状态栏,但在iOS 11上,状态栏和第一个单元格之间有一些空白。

附上iOS 10.3和iOS 11的截图


有没有iOS 11稳定版? 在我看来,这样的问题应该是针对稳定的iOS版本。因为它仍处于测试阶段,在发布之前可能会发生一些变化。 - Aleksey Potapov
这是一个问题,直到iOS 11 beta 5版本。 - Mugunth Chandran
2个回答

4

我在iOS 11中遇到了类似的问题。空白处是页眉和页脚。在iOS<11中,只需将heightForHeaderInSectionheightForFooterInSection设置为CGFLOAT_MIN即可。在iOS 11中,我还需要在viewForHeaderInSectionviewForFooterInSection 中返回nil

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:    (NSInteger)section {
    return CGFLOAT_MIN;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return CGFLOAT_MIN;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return nil;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return nil;
}

3

可能是由于新引入的contentInsetAdjustmentBehavior导致的。

默认情况下设置为.automatic,但可以通过将其切换为.never来禁用:

if #available(iOS 11.0, *) {
    tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.never
}

2
有人解决了这个问题吗?对我来说好像没有改变什么。 - iDev

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接