1

When I try to update the tableview datasource property as shown below

override func viewWillAppear(_ animated: Bool) {
    tableView?.delegate = self
    tableView?.dataSource = self

    super.viewWillAppear(animated)
}

override func viewWillDisappear(_ animated: Bool) {
    tableView?.delegate = nil
    tableView?.dataSource = nil

    super.viewWillDisappear(animated)
}

I am getting an extra space on top of the Tableview when I navigate to other screen and come back to this screen, can anyone help resolving the issue ?

enter image description here

To

enter image description here

Note* I am tried this in simulator with version 10.2

Bharath
  • 2,064
  • 1
  • 14
  • 39
  • Try self.automaticallyAdjustsScrollViewInsets = NO; can be set from code or storyboard itself. – Bharat Modi Mar 15 '17 at 06:50
  • @BharatModi : Ya, I tried that too, but still facing the same issue. – Bharath Mar 15 '17 at 06:53
  • Ara you using headerView? – Bharat Modi Mar 15 '17 at 06:55
  • http://stackoverflow.com/questions/18880341/why-is-there-extra-padding-at-the-top-of-my-uitableview-with-style-uitableviewst – Bharat Modi Mar 15 '17 at 06:58
  • @BharatModi: Yes, I have used header view using a custom cell. I have also removed the headerview and I have also tried without header view, but the issue still persists. – Bharath Mar 15 '17 at 07:11
  • @BharatModi: Thank you, I have also first tried some of the answers in the same link you shared, but I got that issue only when I newly added that tableView?.dataSource = code. – Bharath Mar 15 '17 at 07:12

1 Answers1

0

Try to return the header height as 0. This works most of times. If not also try setting an empty view with 0 height to the header view of the table view.

If you are using the AutomaticDimension to update the cell heights. Make sure to set the .estimatedHeight property to the minimum height you cell can have.

Nishchith
  • 423
  • 5
  • 6