skip to Main Content

I updated my iPhone to iOS 15 and Xcode to 13 version and now my app have a weird padding on top in all screens that has a tableView.
enter image description here

How can I solve this problem?

3

Answers


  1. Chosen as BEST ANSWER

    After a lot of research, I founded the answer in Apple developer documentation: https://developer.apple.com/documentation/uikit/uitableview/3750914-sectionheadertoppadding?language=objc

    So, to solve this problem I added this code in all screen that I was using UITableView:

    if #available(iOS 15.0, *) {
       tableView.sectionHeaderTopPadding = .zero
    }
    

    With this code the gap goes away.


  2. If you want to remove this top padding in all views, you can call this code in AppDelegate:

    if #available(iOS 15.0, *) {
        UITableView.appearance().sectionHeaderTopPadding = .zero
    }
    
    Login or Signup to reply.
  3. The below code is fixed my issue

     if #available(iOS 15, *) {
            UITableView.appearance().tableHeaderView = .init(frame: .init(x: 0, y: 0, width: 0, height: CGFloat.leastNonzeroMagnitude))
        }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search