ios - UITableView contentInset : when scrolling the table to the top, 行在第一个标题上方仍然可见

标签 ios objective-c uitableview cocoa-touch

我有一个由 1 个标题和 1 行按顺序组成的表格:

Header
Row
Header
Row

我已设置 contentInset 来降低表格内容的起始位置:

self.detailTableView.contentInset = UIEdgeInsetsMake(30.0, 0.0, 0.0, 0.0);

它工作得很好,但是,当滚动表格时,表格行的内容在第一个标题上方可见。它们不会消失,而是在顶部边缘 30 像素内可见。如何隐藏它们呢?以便滚动正常工作。

最佳答案

我假设您在表格 View 中有粘性标题。

如果您想在顶部添加填充,您只需设置表头 View 即可:

tableView.tableHeaderView = UIView(frame:CGRect(x: 0, y: 0, width: view.frame.width, height: 30))

关于ios - UITableView contentInset : when scrolling the table to the top, 行在第一个标题上方仍然可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38480444/

相关文章:

ios - 单个 UIViewcontroller 中的两个 UITableView 无法正常工作

ios - 从呈现的 View 更改 UITableViewCell 的属性

ios - NSUserDefaults 不适用于 Swift 中的 UITableView

ios - 从 VoiceOver 隐藏 UITableViewCell

ios - 转换为最新语法时出现错误 "swiftc failed with exit code 1"

ios - UINavigationController 释放财富

ios - 在iOS应用中使用网络服务

ios - 将自定义对象导入多个文件

ios - NSData/setHTTPBody 的最大参数大小?

ios - 如何添加到已保存的 NSUserDefault?