jbm
jbm

Reputation: 1318

iOS plain tableview rows appear behind header

I have a plain tableView—one section—and the rows are appearing behind the header when I scroll. Like this: enter image description here

Is there an easy way to prevent this? I thought it had to do with the contentInset, but that moves the header as well, which is not what I want.

Upvotes: 1

Views: 1713

Answers (2)

JAL
JAL

Reputation: 42489

When setting tableView.tableHeaderView (assuming this is a tableViewHeader and not a section header), make sure you're explicitly setting the height of your header. If you're loading this header from an XIB or Storyboard, the values set in Interface Builder may not carry over to the code.

If this is a section header, you will need to implement the UITableViewDelegate method tableView:heightForHeaderInSection:.

Upvotes: 1

MobileMon
MobileMon

Reputation: 8661

Is this a tableview header or a sectionview header? If sectionView header, that's the default behavior. To make an optical illusion, just set the background color of the view for the section header to be that purple color

you have to use:

viewForHeaderInSection and heightForHeaderInSection. Google for examples of these

Upvotes: 1

Related Questions