DropDownMenuKit
DropDownMenuKit copied to clipboard
Creating Sections
Hi
Just wondering if it is possible to create sections with section headers like in a UITableView?
Thanks
Hi,
Sorry for the very late reply. It won't work out of the box, since DropDownMenu.menuCells is a flat array.
To work around this, you can probably do something along these lines:
- subclass
DropDownMenu - add variable
menuCellsBySectionthat gets updated every timemenuCellsis updated - override the following
UITableViewDataSource/Delegatemethods to usemenuCellsBySectionnumberOfSections(in:)tableView(_:, numberOfRowsInSection:)tableView(_:, heightForRowAt:)tableView(_:, cellForRowAt:)- `tableView(_:, shouldHighlightRowAt:)``
tableView(_:, didSelectRowAt:)
- override
selectMenuCell(_:)to take in account the section
It's probably not exactly easy to do, but if you take a look at the source code, it should be doable.
In the long run, DropDownMenuKit could support sections out of the box or I might tweak the API to simplify the workaround above.