2

I have the same problem with this question: Why is there extra padding at the top of my UITableView with style UITableViewStyleGrouped in iOS7

I have tried so many solutions in this post, but none of them works for me. So i would like to post my project here so that every can take a look and help me find the solution.

enter image description here

https://github.com/happysmile09/TableViewIssue

Description: In tab 2, i scroll table view to bottom, then i move to tab1, the extra top space shows up.

wonea
  • 4,783
  • 17
  • 86
  • 139
Earthgod
  • 662
  • 1
  • 6
  • 21

4 Answers4

2

If you don't need header height you can put following function to make height 0 and minimize the gap

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

enter image description here

Pranjal Bikash Das
  • 1,092
  • 9
  • 27
2

Hope will help you ...

Add 2 row

let indexPath = IndexPath(row: 0, section: 0)

self.tableView.scrollToRow(at: indexPath, at: .top, animated: false)

to 2 function didTapTab1 and didTapTab2

Community
  • 1
  • 1
Thuan Nguyen
  • 244
  • 1
  • 14
0

Hope this will help..Uncheck the Adjust autoScroll view inset..

enter image description here

Bapu
  • 94
  • 5
0

You can try with following

First add self.automaticallyAdjustsScrollViewInsets = NO in your viewDidLoad() method

and then Select TableView > Open Size Inspector > Set SectionHeight of Header to 1

or you can use method also

func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
            return 1.0; 
 }
Maulik Kundaliya
  • 452
  • 3
  • 17