ykyouhei / KYDrawerController

Side Drawer Navigation Controller similar to Android
MIT License
621 stars 158 forks source link

Drawer View is not opening,When coming from another screen #138

Open Hashir524 opened 5 years ago

Hashir524 commented 5 years ago

I will Explain my Problem alittle bit. So i am not initialising drawerview in Appdelegate. instead i am initialising the drawer view in my loginView Controller and Setting the rootViewController From there. Everything is Working fine. But when i go to the other ViewControllers and comeback to the drawer screen through a segue it won't work from here. I tried to reiniallize the drawerview and set the rootController again. but it also didn't work. i will attach my code

App Delegate File Code.

                  var window: UIWindow?
                  var drawerController = KYDrawerController.init(drawerDirection: .left, drawerWidth: 300)

Login Screen Code. Where i am Iniallizing the drawer view

                 let appDel = UIApplication.shared.delegate as! AppDelegate
                 let mainVc = self.storyboard?.instantiateViewController(withIdentifier: "Tabs")
                 let drawerVc = self.storyboard?.instantiateViewController(withIdentifier: "Drawer")

                 let tabbarController = mainVc as? UITabBarController
                 let nextScene = tabbarController?.viewControllers![0] as! MapViewTabViewController
                 nextScene.loginResponse = self.loginResponseglobal
                 let nextListScene = tabbarController?.viewControllers![1] as! 
                  ListViewDashboardViewController

                 appDel.drawerController.mainViewController = mainVc
                 appDel.drawerController.drawerViewController = drawerVc
                 appDel.window?.rootViewController = appDel.drawerController
                 appDel.window?.makeKeyAndVisible()

For the First time it was working. but unfortunatly it is not working when i come from another screen. except LoginScreen. AnyHelp would be appreciated. as i am started in ios.

Hashir524 commented 5 years ago

Any Help Would be much Appreciated. :)

ChetanRajagiri commented 4 years ago

@Hashir524 any update on this?

tsaromkar commented 4 years ago

I did it using storyboard, mine wasn't opening too, while the implementation remains the same, on the login screen instead of

let vc = UIStoryboard.init(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "dashboardMenuViewController") as? DashboardMenuViewController self.navigationController?.pushViewController(vc!, animated: true)

I used this and it worked:
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) let nextViewController = storyBoard.instantiateViewController(withIdentifier: "kyDrawerController") as! KYDrawerController self.present(nextViewController, animated:true, completion:nil)