owenZhang
owenZhang

Reputation: 11

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:

enter image description here

enter image description here

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.

Upvotes: 1

Views: 2257

Answers (2)

user5938635
user5938635

Reputation:

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

Upvotes: 4

Umair Afzal
Umair Afzal

Reputation: 5049

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

enter image description here

Hope it will help.!

Upvotes: 0

Related Questions