我已经用 Objective C 开发了一个应用程序,它在所有 iPhone 手机上运行良好。但是当我在 iPhone X 模拟器中运行这个应用程序时,我不知道如何在 UITableView 的顶部获得一些额外的空间(大约 20-22 像素)。我尝试了所有这些解决方案,但以下方法都没有帮助我:
self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.tableView.bounds.size.width, 0.01f)];
self.edgesForExtendedLayout = UIRectEdgeNone;
[tblProducts setSectionHeaderHeight:0];
self.automaticallyAdjustsScrollViewInsets = NO;
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return CGFLOAT_MIN;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return CGFLOAT_MIN;
}
我知道这可以通过设置我的表视图 contentInset 来实现,如下所示:
tblProducts.contentInset = UIEdgeInsetsMake(-30, 0, 0, 0);
iPhone X 是否有其他解决方案来解决此问题?
我在 ViewDidLoad 中检查了我的表视图框架,它是(0, 64, WIDTH, HEIGHT),状态栏有问题吗?
请建议我。先感谢您!