0

I have UITableViewController as a root of UINavigationController. And it always appears with a strange white strip at the top

enter image description here

(and the height of that white strip in always height of status bar). If I change background color of tableView to red, strip gets red, so it means that the problem is in UITableViewController

I thought that may be the problem is because of table view header or section header, so I added this code to check

override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 10
    }

    override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        let view = UIView()
        view.backgroundColor = UIColor.green
        return view
    }

    func configureTabeView() {
//        self.tableView.contentInset = UIEdgeInsets(top: -1, left: 0, bottom: 0, right: 0)
        let viewHeader = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: 1))
        viewHeader.backgroundColor = UIColor.red
        self.tableView.tableHeaderView = viewHeader
        tableView.clipsToBounds = true
    }

But after that it looks like enter image description here

Where red strip is table header, greed strip is section header. And there is a strange white strip, and scroll indicators have the same offset as white strip height.

Paul T.
  • 4,938
  • 7
  • 45
  • 93
  • Maybe you are using the tableview in storyboard. Check the auto-layout for the tableview, if the top constraint has layout margins in ticked mode? – Alejandro Vargas Oct 20 '17 at 04:49
  • from the scroll indicator u can get to know that the problem is not inside the tableview, maybe check tableview constraints, or status bar things. – NF Lee Oct 20 '17 at 04:49
  • See: https://stackoverflow.com/questions/38810005/view-doesnt-go-under-status-bar-and-status-bar-is-black – Mars Oct 20 '17 at 04:52
  • Or better source: https://stackoverflow.com/questions/19143353/why-does-uiviewcontroller-extend-under-uinavigationbar-while-uitableviewcontrol/19143661#19143661 – Mars Oct 20 '17 at 04:56

1 Answers1

0

The only thing that helped me is to set in storyboard Contents Insets to Never enter image description here

Paul T.
  • 4,938
  • 7
  • 45
  • 93