Search code examples
iosswiftxcodeswrevealviewcontroller

How to logout when using SWRevealViewController controller?


I am using SWRevealViewController in my app..I have login screen my app first..on login button click i load front view controller and left side bar (using SWRevealViewController) but how to logout from SWRevealViewController on logout button click and goto login screen..? i am unable to logout..

following is the code on login button click..

    let frontNavigationController:UINavigationController
    let rearNavigationController:UINavigationController

    let revealController = SWRevealViewController()
    var mainRevealController = SWRevealViewController()

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let sidebar = storyboard.instantiateViewController(withIdentifier:  "MenuTableView")as! MenuTableView
    let homepage = storyboard.instantiateViewController(withIdentifier: "Map_VC") as! MapViewController
    frontNavigationController =  UINavigationController(rootViewController: homepage)
    rearNavigationController = UINavigationController(rootViewController: sidebar)

    revealController.frontViewController = frontNavigationController
    revealController.rearViewController = rearNavigationController
    revealController.delegate = self
    mainRevealController  = revealController
    self.window?.rootViewController = mainRevealController

    UINavigationBar.appearance().barTintColor = UIColor(red: 235.0/255, green: 113.0/255, blue: 158.0/255, alpha: 1.0)
    UINavigationBar.appearance().tintColor = UIColor.white

Solution

  • Try this:

     let goNext = storyBoard.instantiateViewController(withIdentifier: "storyboardID") 
     let customNavigation = UINavigationController(rootViewController: goNext!)
     self.present(customNavigation, animated: true, completion: nil)