分组UITableView底部有20px的额外填充 [英] Grouped UITableView has 20px of extra padding at the bottom
问题描述
在iOS 6中,分组表视图似乎在底部有额外的填充(iOS 5没有它),但我找不到任何表明这是正确/预期行为的文档。
Grouped table views seem to have extra padding on the bottom in iOS 6 (iOS 5 does not have it), but I can't find any documentation that suggests this is correct / expected behavior.
这也影响了示例项目,例如 TableViewSuite
中的 SimpleTableView
项目例。我想我必须将 AppDelegate
中的样式更改为已分组,并将SDK更新为iOS 6,但没有对该项目进行任何其他更改。
This affects the example projects as well, for instance the SimpleTableView
project in the TableViewSuite
example. I think I had to change the style in the AppDelegate
to 'grouped', and updated the SDK to iOS 6, but no other changes have been made to the project.
调查显示,为页眉和页脚视图保留 10px
,加上一些 20px
无法计算。
没有实际的页眉或页脚视图( tableHeaderView
和 tableFooterView
是 nil
,并实现并返回 nil
,例如 viewForFooterInSection
什么都不做。
我在tableView上找不到任何'20'值,虽然我可能错过了一些东西。
Investigating revealed that there are 10px
reserved for header and footer views, plus some 20px
that can't be accounted for.
There are no actual header or footer views (tableHeaderView
and tableFooterView
are nil
, and implementing and returning nil
for e.g. viewForFooterInSection
does nothing).
I cannot find any '20' value on the tableView itself, though I may have missed something of course.
为页脚添加零大小的视图什么都不做,但添加 1px
方形视图会导致额外的填充消失。例如:
Adding a zero-size view for the footer does nothing, but adding a 1px
square view causes the extra padding to vanish. e.g.:
tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0,0,1,1)];
它仍占用 1px
的高度,所以底部填充现在 11px
,但这远远不如20。现在将 sectionFooterHeight
设置为0将导致只有 1px
的底部空间。
It does take up 1px
of height still, so the bottom padding is now 11px
, but this is far less noticeable than 20. And now setting the sectionFooterHeight
to 0 will result in only 1px
of bottom-space.
我的问题是:什么?我怎样才能完全删除它?这不是任务关键任务,但它非常奇怪,不可取,而且据我所知,它没有记录。
My question is: what? And how can I completely remove it? This isn't anything mission-critical, but it is extremely weird, undesirable, and as far as I can tell it's undocumented.
请注意 - 从Apple开发论坛复制过去的问题。但我有完全相同的问题,我也不明白如何解决它。
Please note - its copy past question from apple dev forum. But I have exactly the same issue and I don't understand how to solve it too.
推荐答案
@frankWhite'解决方案很有效,但这是一个更好的解决方案,以避免输入0.1,0.001或其他,以减少模糊。
@frankWhite' solution works great, but here is a better solution to avoid typing 0.1, 0.001 or others to make it less ambiguous.
// Swift version
func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
// remove bottom extra 20px space.
return CGFloat.min
}
// Objective-C version
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
// remove bottom extra 20px space.
return CGFLOAT_MIN;
}
这篇关于分组UITableView底部有20px的额外填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!