如何使用Objective C iOS从iPhone X的表格视图顶部删除多余的空间 [英] How to remove extra space from the top of the Table View in iPhone X using Objective C iOS

查看:71
本文介绍了如何使用Objective C iOS从iPhone X的表格视图顶部删除多余的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Objective C中开发了一个应用程序,该应用程序在所有iPhone手机上都能正常工作.但是,当我在iPhone X Simulator中运行此应用程序时,我不知道如何在UITableView顶部获得一些额外的空间(大约20-22像素).我尝试了所有这些解决方案,但以下方法均无济于事:

I have already developed an app in Objective C which is working fine in all the iPhone mobiles. But when I am running this app in iPhone X Simulator then I dont know how I am getting some extra space (about 20-22 pixels) in the top of the UITableView. I tried all this solutions, but none of the below helped me :

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设置为:

I know this can be possible by setting my table view contentInset like :

tblProducts.contentInset = UIEdgeInsetsMake(-30, 0, 0, 0);

还有其他解决方案可解决iPhone X的此问题吗?

Is there any other solution to resolve this issue for iPhone X?

我在ViewDidLoad中检查了表格视图框架,它是(0、64,宽度,高度),状态栏是否有问题?

I checked my table view frame in ViewDidLoad, It's (0, 64, WIDTH, HEIGHT), Is there any problem with Status bar?

请建议我.预先谢谢你!

Please suggest me. Thank you in Advance!

推荐答案

您可以尝试将contentInsetAdjustmentBehavior属性设置为Never.

You can try setting contentInsetAdjustmentBehavior property to Never.

在Swift中,我在UICollectionView中有此内容:

In Swift, I have this in UICollectionView:

if #available(iOS 11.0, *) {
    collectionView.contentInsetAdjustmentBehavior = .never
}

在Objective-C中,同样适用于UITableView,如下设置:

In Objective-C, the same applies to UITableView, set it like so:

if (@available(iOS 11.0, *)) {
    [_tableView setContentInsetAdjustmentBehavior: UIScrollViewContentInsetAdjustmentNever];
}

这篇关于如何使用Objective C iOS从iPhone X的表格视图顶部删除多余的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆