swift - How to navigate ViewController when clicking button in alertView -
given code below, when click "accept" button, doesn't navigate secondviewcontroller
, shows black screen. appreciated.
let alertcontroller = uialertcontroller(title: tit!, message: "book now!", preferredstyle: .alert) let declineaction = uialertaction(title: "decline", style: .cancel, handler: nil) alertcontroller.addaction(declineaction) let acceptaction = uialertaction(title: "accept", style: .default) { (_) -> void in let nv=secondviewcontroller() self.presentviewcontroller(nv, animated:true, completion:nil) } presentviewcontroller(alertcontroller, animated: true, completion: nil) alertcontroller.addaction(acceptaction)
to open uiviewcontroller
must instantiate
it. , doing creating object of class.
to so:
let nv = self.storyboard!.instantiateviewcontrollerwithidentifier("storyboardidentifier") as! secondviewcontroller self.presentviewcontroller(nv, animated:true, completion:nil)
this open uiviewcontroller
wants!
Comments
Post a Comment