Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 15 Gap between navigation bar and table view [closed]

With iOS 15 beta and Xcode 13 beta 2 some custom UITableViewControllers has decided to add padding between the navigation bar and the table view.

Steps to reproduce:

Add two UITableViewControllers so the structure looks like this: UINavigationController -> UITableViewController -> UITableViewController.

Add table view delegate method heightForHeaderInSection and return a small value.

In viewDidLoad or viewWillAppear methods make a API call.

Actions to solve the problem:

[self.tableView setSectionHeaderTopPadding:0.0f]; // Not working

[self.tableView setContentInset:-35.0f]; // Works but is not dynamic

Tested on Xcode 13 beta 2, iOS 15 beta 2, iPhone 12 Simulator, iPhone Xs

Demo project showing the issue: Github link

The header section should only be 30 pt/px but it's clearly not:

enter image description here

Link to original Apple Developer forum thread

like image 675
dumle Avatar asked Jul 05 '21 06:07

dumle


1 Answers

You can try using UITableView.sectionHeaderTopPadding like this -

if #available(iOS 15, *) {
    tableView.sectionHeaderTopPadding = 0
}
like image 56
Tarun Tyagi Avatar answered Nov 07 '22 05:11

Tarun Tyagi