I was wondering if there was any way to allow the tableview header of a plain table to scroll with the table?
I am currently using the following method to add my header.
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
For example, many developers make their life harder using a scroll view when a UITableView would be a better choice. Finally, architecture is crucial for table views. The code of the table view data source often ends inside view controllers when it should go into a separate class.
Table views are more versatile than you might think. For example, many developers make their life harder using a scroll view when a UITableView would be a better choice. Finally, architecture is crucial for table views.
Introduced in iOS 6, UITableViewHeaderFooterView takes the reuse functionality of table view cells and makes it available to section headers and footers. You can either use it directly or create a subclass to customize its appearance.
When the user scrolls back to a row, the table view will request its data again. The tableView(_:numberOfRowsInSection:) method tells the table view how many elements a section contains. The table view uses this information to prepare its scrolling area and display a scroll bar of the appropriate size.
Actually the tableHeaderView
scrolls with table. This is not the case for section header views. If you have only one section then you can have the header view as tableHeaderView
.
table.tableHeaderView = aUiView;
If you have more than one sections and all of them have their own header views, then you have no choice than leaving the header views behave in their own ways. Or, you can imitate the header view by making/configuring/customizing the first row of each section look like header view and remove the actual section header views.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With