Terry Terry - 3 months ago 26
Swift Question

swift weird tableview scroll behaviour from tableView header section

I have a weird tableview header behaviour when scrolling.
when i scroll up the header sticks on top of the view and a cell scrolls under the header. if i scroll up more then the header starts scroll with the tableview.
thanks please have a look at GIF i added.
cell goes underneath the header

Answer

Set this in viewDidLoad():

automaticallyAdjustsScrollViewInsets = false

And you can set content insets. Like this:

tableView.contentInset = UIEdgeInsets(top: <#T##CGFloat#>, left: <#T##CGFloat#>, bottom: <#T##CGFloat#>, right: <#T##CGFloat#>)