I'm using LGSideMenuController as my side navigation panel. I have 4 view controller in it and i want to push a new view controller from side menu when pressed an option. i also have UITabarBarController embeded after the LGSideMenuController in storyboard.
And i'm unable to push view controller.
can anyone help me with that?
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyBoard.instantiateViewController(withIdentifier: "ProfileSBID") as! ProfileVC
let navigationController = sideMenuController!.rootViewController as? UINavigationController
self.navigationController?.pushViewController(viewController, animated: true)
I am having a hard time what it is you exactly want, visually speaking, but:
Are you aware that in line 4 of above snippet you are not using the UINavigationController that you for in line 3?
It reads as if you're not invoking that code from within the controller hierarchy that resides inside LGSideMenuController (which is a type/package I do not know, btw), but from elsewhere. If there is a nearer UINavigationController from that point, you'd get this one. It might even be nil.
If you want to use the navigationController from line 3, delete the self. in line 4.
Should that not be what you want I don't see why you have line 3 in the first place...
Also, I'd avoid using force-unwraps, specifically if you optional-cast them afterwards anyways. And there is a newer method to instantiate typed view controllers from storyboards, so line 2 can be replaced with:
let viewController: ProfileVC = storyBoard.instantiateViewController(identifier: "ProfileSBID")
That would get rid of the other force-unwrap (but obviously would still crash if the storyboard does not have a matchingly typed view controller with that id).