evnaz / ENSwiftSideMenu

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

How to open sidemenu from detailviewcontroller #133

Open khanboy1989 opened 8 years ago

khanboy1989 commented 8 years ago

I have used this excellent open source project to obtain sliding menu. However I have two problems

When I move to detailviewcontroller from mainviewcontroller the ENSideMenu wont open again and at the same time I want to open ENSideMenu from the detailviewcontroller if it is possible..

Please I need help very urgently

Here is my View Controllers

randimimage

At the same time here is my ThirdViewController DetailViewController and RightSideMenuNavController Codes

RightSideNavController:

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

    let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main",bundle: nil)
    var destViewController  = UIViewController()

    switch (indexPath.row) {

    case 0:

          destViewController = mainStoryboard.instantiateViewControllerWithIdentifier("ViewController")

        break

    case 1:

        destViewController = mainStoryboard.instantiateViewControllerWithIdentifier("Second")

        break

    case 2 :

        destViewController = mainStoryboard.instantiateViewControllerWithIdentifier("Third")

        break

    default: break

    }

    let navController = sideMenuController() as! UINavigationController
    navController.pushViewController(destViewController, animated: true)

}

MainViewController (ThirdViewController)

override func viewDidLoad() { super.viewDidLoad()

    self.sideMenuController()?.sideMenu?.delegate = self

    // Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

@IBAction func showDetails(sender: AnyObject) {

self.performSegueWithIdentifier("Detail", sender: self)

}

func sideMenuShouldOpenSideMenu() -> Bool {
    print("sideMenuShouldOpenSideMenu")
    return true
}

DetailViewController

override func viewDidLoad() { super.viewDidLoad()

    self.sideMenuController()?.sideMenu?.delegate = self

    // Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

@IBAction func openMenu(sender: AnyObject) {

  sideMenuController()?.sideMenu?.showSideMenu()

}
@IBAction func goBack(sender: AnyObject) {

self.performSegueWithIdentifier("Back", sender: self)

}

func sideMenuShouldOpenSideMenu() -> Bool {
    print("sideMenuShouldOpenSideMenu")
    return true
}

Please any help will be appreciated