in plainsytle tableview , we set headerViews for each section by delegate method
-(UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section
so,when i scrolling up tableview , the first section's headerView is always showing on the top of tableview before the section totally disappear on the tableview , then the second section's headerView will show on the top of tableview instead . so my question is how can i make headerView scroll accompanying with uitableViewCell , just like group style tableview ?
Swift:
As Hani Ibrahim pointed out you need to subclass UITableView. Apple says you :
must specify style at creation.
So:
Notice how my super.init uses .grouped as the style. For this style of tableview (.grouped) Apple also says:
Then you can call the following tableView delegate methods:
viewForHeaderInSection
andheightForHeaderInSection
(notice those are for headers only, use the footer counterparts if you want footers too)And that should do it! Good luck.
You can change the style of the tableView.