ios - How can I prevent the unbalanced calls method during a container transition? -
i'm getting "unbalanced calls begin/end appearance transitions " when transition between child view controllers.
i'm pretty sure it's because add child view controller , transitionfromviewcontroller methods adds again.
but need add subview setup constraints auto layout.
@ibaction func flipaction(sender: anyobject) { var nextviewcontroller = self.currentviewcontroller == self.frontviewcontroller ? self.backviewcontroller : self.frontviewcontroller self.currentviewcontroller.willmovetoparentviewcontroller(nil) self.addchildviewcontroller(nextviewcontroller) nextviewcontroller.view.frame = self.containerview.frame self.containerview.addsubview(nextviewcontroller.view) nextviewcontroller.view.settranslatesautoresizingmaskintoconstraints(false) self.containerview.addconstraints(nslayoutconstraint.constraintswithvisualformat("h:|-[back]-|", options: nslayoutformatoptions.allzeros, metrics: nil, views: ["back": nextviewcontroller.view])) self.containerview.addconstraints(nslayoutconstraint.constraintswithvisualformat("v:|-[back]-|", options: nslayoutformatoptions.allzeros, metrics: nil, views: ["back": nextviewcontroller.view])) self.transitionfromviewcontroller(self.currentviewcontroller, toviewcontroller: nextviewcontroller, duration: 1, options: uiviewanimationoptions.transitionflipfromright, animations: { () -> void in }) { (success: bool) -> void in self.currentviewcontroller.removefromparentviewcontroller() nextviewcontroller.didmovetoparentviewcontroller(self) self.currentviewcontroller = nextviewcontroller } }
how can prevent unbalanced calls method?
Comments
Post a Comment