0

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 Answers2

0

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.

FruitAddict
  • 2,042
  • 15
  • 16
  • slidingViewController property is not accessible. Is there any import needed. I am a newbie in swift. @FruitAddict – Jagajith Monappan Kalarickal Sep 03 '15 at 05:07
  • In your obj-c bridge you need to import `UIViewController+ECSlidingViewController.h` It's an extension to UIViewController that will search the view tree for the nearest sliding view controller. If you're using cocoapods just add `#import ` – FruitAddict Sep 03 '15 at 05:09
  • I am using cocoapods. In swift do we use #import? When i tried as you suggested i got some error. @FruitAddict – Jagajith Monappan Kalarickal Sep 03 '15 at 05:18
  • You must've created the objective c bridge somewhere to even get ECSlidingController to work. Just import it the same way you imported the other class :) – FruitAddict Sep 03 '15 at 05:23
  • After adding cocoapods, i have only set the user defined runtime attributes to make ECsliding work. I haven't add any objective c bridge myself. @FruitAdddict – Jagajith Monappan Kalarickal Sep 03 '15 at 05:30
  • Read up on how to create an obj-c bridge. It's recommended to do it this way and is easier to maintain. – FruitAddict Sep 03 '15 at 05:55
  • After adding obj-c bridge now i am able to access the function, but the self.slidingViewController?.resetTopViewAnimated(true) is not working. Showing MenuTableViewController does not have a member named slidingViewController @FruitAddict – Jagajith Monappan Kalarickal Sep 03 '15 at 08:37
  • var slidingViewController: ECSlidingViewController = self.view.window?.rootViewController as! ECSlidingViewController slidingViewController.resetTopViewAnimated(true) At last worked thanks @FruitAddict – Jagajith Monappan Kalarickal Sep 03 '15 at 10:19
0
var slidingViewController: ECSlidingViewController = self.view.window?.rootViewController as! ECSlidingViewController  
slidingViewController.resetTopViewAnimated(true)