1

I am building an app that uses a side menu, within that side menu is a UITableView displaying some text. When you click on one of those, it takes you to another ViewController. I searched the internet for it but didn't find something useful. My question is: how to make a "submenu" inside the tableview, so that when you click on it, it needs to dropdown and show more options.

I don't have any idea how to do this, so a little help would be really appreciated!

Thanks

Fattie
  • 30,632
  • 54
  • 336
  • 607
Bram Roelandts
  • 462
  • 5
  • 24
  • A simple solution is to just have a container view [simple tutorial here](http://stackoverflow.com/questions/23399061/objective-c-how-to-add-a-subview-that-has-its-own-uiviewcontroller/23403979#23403979) and just have it appear/disappear as needed. If you're just beginning with iOS, you'll need to use container views (they are used everywhere these days) so it's a good chance to learn this easy system. – Fattie Nov 03 '15 at 15:08

2 Answers2

1

You may use sections for building a submenu structure. You can overwrite viewForHeaderInSection for each section for which you don't want to display the section header and return an empty UIView object with a size of (0.0, 0.0) or even null. (I never tried returning null/nil myself.)

For each menu on the highest level you have exactly one corresponding section and each of them has just one row. They may or may not have header views.

For the menu that you want to display as submenu you set the header view of the related section accordingly and then have one row for each item of the submenu.

Unfortunately this allows for a 2-level menu heirachry only. But on the upside everything you need is already sort of build-in into cocoa touch.

Hermann Klecker
  • 13,792
  • 4
  • 45
  • 69
0

Perhaps this could possibly help you achieve what you are looking for:

Expandable Sections UITableView IndexPath SWIFT

You may have to have a good look through the code but it should set you on the right track.

Community
  • 1
  • 1
Liam
  • 2,369
  • 1
  • 12
  • 16