evnaz / ENSwiftSideMenu

A simple side menu for iOS written in Swift.
MIT License
1.82k stars 282 forks source link

Side Menu Won't Collapse When Click Current Menu Item #147

Closed XinwenCheng closed 8 years ago

XinwenCheng commented 8 years ago

Hi @evnaz ,

When I click the current menu item, how can I make the side menu collapse automatically?

Thanks!

XinwenCheng commented 8 years ago

OK, I got it. Need to use following code by myself.

self.sideMenuController()?.sideMenu?.hideSideMenu()
amjad401 commented 8 years ago

Where did you put this code? I need this

XinwenCheng commented 8 years ago

To instance an ENSideMenu like following,

sideMenu = ENSideMenu(sourceView: self.view, menuViewController: LeftSideNavigationMenuViewController(), menuPosition: .Left)

There's LeftSideNavigationMenuViewController which contains table view of navigation items, and in its override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) function, I put following code,

if indexPath.row == selectedMenuItem {
    self.sideMenuController()?.sideMenu?.hideSideMenu()
    return
}

selectedMenuItem = indexPath.row

Hope this helps!

amjad401 commented 8 years ago

Thank you very much!!