我的tableview的底部都有一个额外的空间,因为你在图片中看到:
在所有的tableView行有71pt的固定高度。
在我的情况,这是由于在UITableView的底部具有默认高度18的页脚。将其设置为1除去底部的额外空间。
我有这个问题,当我翻了一个聊天消息屏幕我的UITableView颠倒。
之前我翻转表视图,内容嵌入在顶部留下的空白区域,这样,当我们滚动一路攀升,内容没有被导航栏挡住。有一次,我把它弹插图被移到了底部。
更改“内容插图”从不在你的UITableView的大小督察摆脱在最后这个空间。
这是如何它可以很容易通过故事板(iOS的11)是固定的:
选择表视图>尺寸检查>内容插图:从不
在我的情况的tableView编程方式创建,我不得不设置qazxsw POI以使该空间消失
在这种情况下,你可以给的tableview底部空间0到它的父,它会工作,我认为还是可以做的,
tableView.estimatedRowHeight
或者你还可以像下面,
较低的值应为1.0。
tableView.tableFooterView = UIView();
@ urgentx的- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger )section {
if(section == 0) {
return 6;
} else {
return 1.0;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger )section {
return 5.0;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger )section {
return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger )section {
return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
}
了大部分的我想要的东西,但没有到达那里的所有道路。我在一个类似的情况(倒挂的UITableView的聊天应用程序),但是他们的建议完全禁止,因为这意味着实现代码如下将由家庭指示器和任何两个被剪切安全区的行为是不是像iPhone X设备可取顶部的导航栏。
我也为了使tableview中仍然正确避免安全区域以下,而倒:
answer
接着:
override func viewDidLoad() {
super.viewDidLoad()
self.automaticallyAdjustsScrollViewInsets = false
self.tableView.contentInsetAdjustmentBehavior = .never
}
这在本质上复制override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
//fetch the safe area in layoutSubviews since this it's possible that they can change when the device is rotated
let safeArea = self.tableView.safeAreaInsets
//insets are **flipped** because the tableview is flipped over its Y-axis!
self.tableView.contentInset = .init(top: safeArea.bottom, left: 0, bottom: safeArea.top, right: 0)
}
的行为,但与整个Y轴翻转的插图。
万一有一个嵌入式导航控制器,检查“显示工具栏”中创建视图控制器底部间距。只要取消它。
contentInsetAdjustmentBehavior = .automatic