简体   繁体   中英

Can't present login screen before tabbarcontroller

I have code for multiple screens in my application. I'm trying to add in a TabBarController for the app once a user has logged in, however now the application is ignoring the login view controller. Here's my code for my login screen:

import UIKit
import CoreML
import Vision
import FirebaseAuth

class ViewController: UIViewController {




@IBOutlet weak var emailTextfield: UITextField!
@IBOutlet weak var passwordTextfield: UITextField!


@IBAction func createAccountTapped(_ sender: Any) {

    if let email = emailTextfield.text, let password = passwordTextfield.text {

        Auth.auth().createUser(withEmail: email, password: password, completion: { user, error in

            if let firebaseError = error {
                print(firebaseError.localizedDescription)
                return
            }



            self.presentVisRecogScreen()
        })
    }
}

@IBAction func loginTapped(_ sender: Any) {

    if let email = emailTextfield.text, let password = passwordTextfield.text {

        Auth.auth().signIn(withEmail: email, password: password, completion: {(user, error) in
            if let firebaseError = error {
                print(firebaseError.localizedDescription)
                return
            }
            self.presentVisRecogScreen()
        })
    }
}

func presentVisRecogScreen(){

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let viewController = storyboard.instantiateViewController(withIdentifier :"myTabBar")
    self.present(viewController, animated: true)
}

}

It was my understanding that the application would present this screen, and once the presentVisRecogScreen function was called it would then show the Tabbed application. Where am I going wrong?

I found the issue, which I'm sure is a blatant newbie error. I hadn't ticked the box to say that my login screen was the Initial View Controller.

Works perfectly now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM