Swift Unbalanced calls to begin/end appearance transitions for

13,538

Solution 1

This issue occurs if you trying to push new view controller while previous transaction (animation) in progress. So please check your code flow and make the appropriate changes. Check your dismiss and present view animations. You can use property setAnimation to 'YES/NO'resolve this

Set animated:NO, may be solve your problem

Solution 2

To me this weird issue was occurring due to following line after implementation of UISplitViewController

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
.
.
.
    // splitViewController.preferredDisplayMode = .PrimaryOverlay
.
.
.
    }

By commenting this line in didFinishLaunchingWithOptions issue was resolved.

Share:
13,538

Related videos on Youtube

Mike Walker
Author by

Mike Walker

Updated on September 15, 2022

Comments

  • Mike Walker
    Mike Walker over 1 year

    This has been stumping me for a while now. I have a UISplitViewController inside a UITabBarController. The master view is a TableView. When I click on a cell, I bring up a very basic view controller with just a UIButton centered. Here is the code for the view controller:

    class TestViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
        @IBOutlet weak var button: UIButton!
    
        override func viewDidLoad() {
            super.viewDidLoad()
        }
    
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
    
        @IBAction func buttonPressed(sender: AnyObject) {
            let pickerC = UIImagePickerController()
            pickerC.delegate = self
    
            pickerC.modalPresentationStyle = .Popover
            pickerC.popoverPresentationController?.sourceView = button as UIView
            pickerC.popoverPresentationController?.sourceRect = (button as UIView).bounds
            pickerC.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.Any
            self.presentViewController(pickerC, animated: true, completion: nil)//4
        }
    
        func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {
            self.dismissViewControllerAnimated(true, completion: nil)
        }
    
        func imagePickerControllerDidCancel(picker: UIImagePickerController) {
           self.dismissViewControllerAnimated(true, completion: nil)
        }
    }
    

    If I click cancel or select and image, the picker controller dismisses properly. The problem comes when I click on the back button to return to the TableView, I receive:

    Unbalanced calls to begin/end appearance transitions for <TestViewController: 0x7fb882a72380>.
    

    The TestViewController is very basic, so why would this be happening?

  • Mike Walker
    Mike Walker about 9 years
    Thank you for the help. Strangely enough it helped me track down the problem, which was in the UITabBarController's viewDidAppear method, I was missing the line: super.viewDidAppear(animated).
  • Sonic Master
    Sonic Master about 6 years
    @MikeWalker simply call super.viewDidAppear saved my daaaayyyyyy.
  • Sohaib Siddique
    Sohaib Siddique over 3 years
    @MikeWalker you saved my day, i also missed super, thanks