In implementing the following cross-dissolve custom segue on a button press (learned at 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 am getting the "Unbalanced calls to begin/end appearance transitions" warning/error.
I have thoroughly searched many stackoverflow questions:
Unbalanced calls to begin/end appearance transitions for <UITabBarController: 0x197870>
- my response: I am using the segue as a button press not within a TabBar Controller so this answer does not apply
Keep getting "Unbalanced calls to begin/end appearance transitions for <ViewController>" error
- my response: I tried two methods: 1) All segues done programatically with self.performseguewithidentifier 2) All segues done via interface builder, by click dragging the buttons and selecting my custom transition from the attributes pane of the selected segue. Both still yielded the aforementioned error.
- my response: Same as above, double checked all segues were only performed once, either programmatically or via interface builder, not both.
- my response: I am not using a table view controller nor a navigation controller in my segues, so this answer does not apply.
Unbalanced calls to begin/end appearance transitions for UITabBarController
my response: I tried making all segues perform within a dispatch as 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 to no avail, the warning/error still pops up.
I'm aware what the error means, that it's attempting to present a new viewcontroller before the previous one loads, but not sure how to tackle it.
The only lead I have is that the previous (source) viewcontroller pops up real quickly before the final viewcontroller loads, as seen at 0:04 at
The glitch only actually appears I would guess around 5% of the time, however.
Any ideas?