简体   繁体   中英

Why is there extra space at the top and bottom of my UITableView

Starting in iOS 9.3.2, there is extra space at the top and bottom.

Here are some examples:

在此处输入图片说明

在此处输入图片说明

There is about 20 pixels of unexplained padding. Can anyone explain where do they come from?

self.automaticallyAdjustsScrollViewInsets = NO;

This doesn't work for me.

You can do this by using contentInset property for UITableView

self.tableView.contentInset = UIEdgeInsetsMake(-20, 0, -20, 0);

This will remove the extra spaces from top and bottom

1.Check if your table view in touching the edges of viewcontroller.

2.If not then make it touch each side of th view controller by expanding your tableview

3.Select your table view from Document outline and go to Pin menu of autolayout

4.Add 4 pin constraints and set the value to 0 as you can see in image below

5.Uncheck "Constraints to margins" and click add 4 constraints

在此处输入图片说明

Hope it will help.!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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