bobster
bobster

Reputation: 311

Swift Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x7fd61043fce0>

Good day, I'm new around here, hope this question isn't too silly.

I got the warning Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x7fd61043fce0> during runtime. However, I cannot find anywhere in my code that has UINavigationController, nor any other file in the project.

import UIKit
class ViewController: UIViewController,PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate, FBLoginViewDelegate {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    //self.navigationController?.navigationBarHidden = true

    if(PFUser.currentUser() == nil){


        var logInViewController = PFLogInViewController()
        logInViewController.delegate = self

        //customize logInViewController
        logInViewController.fields = PFLogInFields.UsernameAndPassword | PFLogInFields.LogInButton | PFLogInFields.PasswordForgotten | PFLogInFields.Facebook | PFLogInFields.SignUpButton

        logInViewController.facebookPermissions = ["public_profile", "email", "user_friends"]

        logInViewController.logInView.logo  = UIImageView(image: UIImage(named: "Logo"))

        //create a signUpViewController instance
        var signUpViewController = PFSignUpViewController()
        signUpViewController.delegate = self

        //add signUpViewController instance to logInViewController for signUp module.
        logInViewController.signUpController = signUpViewController

        self.parentViewController?.presentViewController(logInViewController, animated: true, completion: nil)

    }else{
        FBSession.activeSession().close()
    }

}

Am I missing something that I should check?

Upvotes: 1

Views: 3471

Answers (1)

Rory McKinnel
Rory McKinnel

Reputation: 8014

I would move the presentation of the login to viewWillAppear from viewDidLoad. This will make sure everything is setup in the current controller before you show another.

Also present the login controller from self and not self.parentViewController. This could be where your error comes from.

Upvotes: 1

Related Questions