ios - My ViewControllers is not dismissing properly -
i have, 3 viewcontrollers, idea is, viewcontroller viewonecontroller, , viewtwocontroler, want go viewcontroller directly, when do, memory goes little bit, viewcontrollerdelegate
protocol viewcontrollerdelegate{ func viewcontrollerdidfinish(controller: viewcontroller) }
this viewtwo trying go viewcontroller
protocol viewtwodelegate{ func viewtwodidfinish(controller: viewtwo) } class viewtwo: uiviewcontroller, viewcontrollerdelegate { var button: uibutton! var delegate: viewtwodelegate? = nil override func viewdidload() { super.viewdidload() button = uibutton.buttonwithtype(uibuttontype.system) as! uibutton button.frame = cgrectmake(self.view.frame.size.width/2 - button.frame.size.width, 100, 250, 50) button.layer.cornerradius = 3 button.backgroundcolor = uicolor.bluecolor() button.center.x = self.view.center.x button.settitle("viewcontroller", forstate: uicontrolstate.normal) button.addtarget(self, action: "viewcontrolleraction:", forcontrolevents: uicontrolevents.touchupinside) button.tintcolor = uicolor.whitecolor() view.addsubview(button) } func viewcontrolleraction(sender: uibutton!){ var materialsviewcontroller: viewcontroller = uistoryboard(name: "main", bundle: nil).instantiateviewcontrollerwithidentifier("view") as! viewcontroller self.presentviewcontroller(materialsviewcontroller, animated: true, completion: nil) } func viewcontrollerdidfinish(controller: viewcontroller){ self.dismissviewcontrolleranimated(true, completion: nil) }
other 2 controllers same
edit: tried
self.dismissviewcontrolleranimated(true, completion: { () -> void in self.presentingviewcontroller?.dismissviewcontrolleranimated(true, completion: nil) })
and dismisses not presented, when tried this
self.dismissviewcontrolleranimated(true, completion: nil) self.presentingviewcontroller?.dismissviewcontrolleranimated(true, completion: nil)
it works, 2 viewcontrollers, if need more?
i need help, please
Comments
Post a Comment