繁体   English   中英

UITableView 不会在 iPad 上填满整个屏幕

[英]UITableView does not fill out entire screen on iPad

我在Main.storyboard添加了一个UITableView而没有设置任何其他属性。 在 iPhone 上,表格以纵向和横向模式填充,完整的屏幕,这是所需的行为。 但是,在 iPad 上启动应用程序时,表格如下所示:

iPad UITableView

当我向表视图添加以下约束时:

  • 领先的空间到集装箱保证金
  • 到集装箱边距的尾随空间
  • 垂直间距到顶部布局指南
  • 底部垂直间距布局指南

该问题在 iPad(纵向和横向模式)上已修复,但在 iPhone 上,横向模式中的第一个单元格被隐藏:

iPhone UITableView

我怎样才能解决这个问题? 这个问题在 iPhone 的竖屏模式下不会发生,在 iPad 上也不会在两种模式下发生。

顺便说一句,控制器属性“调整滚动视图插入”已启用。

对于插图,请在下面添加此代码

 -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
    [tableView setSeparatorInset:UIEdgeInsetsZero];
}

if ([tableView respondsToSelector:@selector(setLayoutMargins:)]) {
    [tableView setLayoutMargins:UIEdgeInsetsZero];
}

if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
    [cell setLayoutMargins:UIEdgeInsetsZero];
}
}

为了使 tableView 适合所有设备,使其适合整个屏幕,请添加以下显示的约束。

约束

结果 TableView 将是

结果

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM