[英]UITableView does not fill out entire screen on iPad
我在Main.storyboard
添加了一个UITableView
而没有设置任何其他属性。 在 iPhone 上,表格以纵向和横向模式填充,完整的屏幕,这是所需的行为。 但是,在 iPad 上启动应用程序时,表格如下所示:
当我向表视图添加以下约束时:
该问题在 iPad(纵向和横向模式)上已修复,但在 iPhone 上,横向模式中的第一个单元格被隐藏:
我怎样才能解决这个问题? 这个问题在 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.