ios - Unbalanced calls to begin/end appearance transitions with custom segue -
in implementing following cross-dissolve custom segue on button press (learned @ https://www.youtube.com/watch?v=xq9zvslncww):
override func perform() { var src:uiviewcontroller = self.sourceviewcontroller as! uiviewcontroller var dstn:uiviewcontroller = self.destinationviewcontroller as! uiviewcontroller src.view.addsubview(dstn.view) dstn.view.alpha = 0 uiview.animatewithduration(0.75 , delay: 0.1, options: uiviewanimationoptions.transitioncrossdissolve, animations: { () -> void in dstn.view.alpha = 1 }) { (finished) -> void in dstn.view.removefromsuperview() src.presentviewcontroller(dstn, animated: false, completion: nil) } }
i getting "unbalanced calls begin/end appearance transitions" warning/error.
i have thoroughly searched many stackoverflow questions:
unbalanced calls begin/end appearance transitions <uitabbarcontroller: 0x197870>
- my response: using segue button press not within tabbar controller answer not apply
keep getting "unbalanced calls begin/end appearance transitions <viewcontroller>" error
- my response: tried 2 methods: 1) segues done programatically self.performseguewithidentifier 2) segues done via interface builder, click dragging buttons , selecting custom transition attributes pane of selected segue. both still yielded aforementioned error.
- my response: same above, double checked segues performed once, either programmatically or via interface builder, not both.
- my response: not using table view controller nor navigation controller in segues, answer not apply.
unbalanced calls begin/end appearance transitions uitabbarcontroller
my response: tried making segues perform within dispatch shown below
let delay = 0.01 * double(nsec_per_sec) let time = dispatch_time(dispatch_time_now, int64(delay)) dispatch_after(time, dispatch_get_main_queue()) { self.performseguewithidentifier("tononfblogin", sender: nil) }
however still no avail, warning/error still pops up.
i'm aware error means, it's attempting present new viewcontroller before previous 1 loads, not sure how tackle it.
the lead have previous (source) viewcontroller pops real before final viewcontroller loads, seen @ 0:04 @
the glitch appears guess around 5% of time, however.
any ideas?
looks behaviour result of - of yet - undocumented change in recent ios releases. getting frustrated exact issue , lack of satisfying answers i've come this:
// create uiimageview containing uiimage of `view`'s contents func createmockview(view: uiview) -> uiimageview { uigraphicsbeginimagecontextwithoptions(view.frame.size, true, uiscreen.mainscreen().scale) view.drawviewhierarchyinrect(view.bounds, afterscreenupdates: true) let image = uigraphicsgetimagefromcurrentimagecontext() uigraphicsendimagecontext() return uiimageview(image: image) } override func perform() { let src:uiviewcontroller = self.sourceviewcontroller as! uiviewcontroller let dstn:uiviewcontroller = self.destinationviewcontroller as! uiviewcontroller let mock = createmockview(dstn.view) src.view.addsubview(mock) mock.alpha = 0 uiview.animatewithduration(0.75, delay: 0.1, options: uiviewanimationoptions.transitioncrossdissolve, animations: { () -> void in mock.alpha = 1 }, completion: { (finished) -> void in src.presentviewcontroller(dstn, animated: false, completion: { mock.removefromsuperview()}) }) }
createmockview()
create uiimageview
containing snapshot of destination vcs contents , use transition animation. once transition finished real destination vc presented without animation causing seamless transition between both. once presentation done mock view removed.
Comments
Post a Comment