我已经用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中检查了我的tableView框架,它是(0,64,WIDTH,HEIGHT),状态栏是否有问题?
请给我建议。谢谢您提前!