Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating Sections #24

Open
johnallen24 opened this issue May 22, 2018 · 1 comment
Open

Creating Sections #24

johnallen24 opened this issue May 22, 2018 · 1 comment

Comments

@johnallen24
Copy link

Hi

Just wondering if it is possible to create sections with section headers like in a UITableView?

Thanks

@qmathe
Copy link
Owner

qmathe commented Oct 12, 2018

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 menuCellsBySection that gets updated every time menuCells is updated
  • override the following UITableViewDataSource/Delegate methods to use menuCellsBySection
    • numberOfSections(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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants