ios - How to instantiate SWRevealController programmatically with the value? -
my goal instantiate swrevealcontroller programmatically seems like, every time crash
here's code
if let vc = self.storyboard?.instantiateviewcontroller(withidentifier: "onjobviewcontrollerid") as? onjobviewcontroller { var firstname = "aegon" vc.drivername.text = firstname let navcontroller = uinavigationcontroller(rootviewcontroller: vc) navcontroller.setviewcontrollers([vc], animated:true) self.revealviewcontroller().setfront(navcontroller, animated: true) }
onjobviewcontroller viewcontroller
always crash in here.
for clarity here storyboard
the main view controller
setfront segue
setrear segue
try :-
let frontnavigationcontroller:uinavigationcontroller let rearnavigationcontroller:uinavigationcontroller let revealcontroller = swrevealviewcontroller() var mainrevealcontroller = swrevealviewcontroller() let objstoryboardmain = uistoryboard(name: "main", bundle: nil) let sidebar = objstoryboardmain.instantiateviewcontroller(withidentifier: "viewsidemenu")as! sidemenuviewcontroller let homepage = objstoryboardmain.instantiateviewcontroller(withidentifier: "viewhomepage") as! homepageviewcontroller frontnavigationcontroller = uinavigationcontroller(rootviewcontroller: homepage) rearnavigationcontroller = uinavigationcontroller(rootviewcontroller: sidebar) revealcontroller.frontviewcontroller = frontnavigationcontroller revealcontroller.rearviewcontroller = rearnavigationcontroller revealcontroller.delegate = self mainrevealcontroller = revealcontroller self.window?.rootviewcontroller = mainrevealcontroller self.window?.makekeyandvisible()
reference:-
https://github.com/john-lluch/swrevealviewcontroller
Comments
Post a Comment