Hi guys inside my tableView class i have following enum
enum tabelSecion {
case action
case drama
case comedy
}
i need to use this enum to have 3 different section header. also i created a nib to represents a custom sectionHeaderCell which has only a label inside it.how can i show section headers? appreciate for your help
You can do it by extending your enum with a dynamic var
SectionTitle
.By making you enum an Int, it is possible to init it with a rawValue. The rawValue to init it is the section it you get from the TableView Method.
The CaseIterable is also quit nice so you can get the number cases (=sections) from it for the
numberOfSections
Method.Edit: To display a
headerView
for each section of the tableView change the TableViewstyle toGrouped
In your code just provide the tableView with the correct amount of sections.
If you really need a custom HeaderView you may use the following Method to do so