Hide menu bar in ECSlidingViewController in an option in swift

415 Views Asked by At

I am using ECSlidingViewController for the menu navigation. I have a option logout on which on selection logout the user. When the user login agin the menu bar will be visible instead of hidden. Swift code to hide the menu bar on logout selection.

import Foundation
import UIKit
import Parse

class MenuTableViewController: UITableViewController {
@IBAction func unwindToMenuViewController(segue: UIStoryboardSegue) {
}
override func viewDidLoad() {
    super.viewDidLoad()
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}
override func tableView(tableView: UITableView,   didSelectRowAtIndexPath indexPath: NSIndexPath) {
    if indexPath.row == 4 {
        PFUser.logOut()

        var loadLoginPage: UINavigationController = self.storyboard?.instantiateViewControllerWithIdentifier("LoginNavigationController")! as UINavigationController
        self.presentViewController(loadLoginPage, animated: false, completion: nil)
    }
}
}
2

There are 2 best solutions below

0
On
var slidingViewController: ECSlidingViewController = self.view.window?.rootViewController as! ECSlidingViewController  
slidingViewController.resetTopViewAnimated(true)
8
On

Try self.slidingViewController?.resetTopViewAnimated(true). Then it's just a matter of removing the pan gesture recognizer of the ECSlidingViewController from the current top view and disabling any buttons that might open the menu.