-3

I made sidemenu. but i have some question. when i clicked button on the sidemenu, appear an other side button. look like this image

enter image description here

when i clicked sidemenu button, appear subSidemenu. I don't know how to say this function.

chen
  • 39
  • 1
  • 2
  • 6
  • 1
    Possible duplicate of [Expandable tableView in iphone](https://stackoverflow.com/questions/11626028/expandable-tableview-in-iphone) – dahiya_boy May 01 '18 at 05:06
  • This functionality is called **Expandable-collapse tableview** & there are lots of answer available for this . Thats why I marked it duplicate. – dahiya_boy May 01 '18 at 05:08

1 Answers1

0

Firstly if you want to show a list of values which are collapsable then you need a UITableView. Make your SideMenus as sections and rows as SubSideMenus. And you would like to have that feature when user tap so implement tableview's numberOfRows method like this

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    let sideMenu = mySideMenus[section]
    return sideMenu.isCollapsed ? 0 : sideMenu.subSideMenus.count
}

And when the header is tapped you need to call tableView.reloadSections(sections: [IndexSet], with: UITableViewRowAnimation) to reload that section.

I don't know if this is was your exact question but sidebar is easy to implement for your app. And you don't need buttons when working with tableView.

Amber K
  • 700
  • 1
  • 5
  • 20