Search code examples
iosswiftxcodeseguetextfield

UITextField and UIButton unresponsive after signOut segue swift


In my Xcode project, after signing out and performing a segue, my text fields and buttons are unresponsive and won't show the keyboard, editing mark or allow me to edit. I am not getting an error anywhere, ​however.

ViewController.swift:

override func viewDidLoad() {
    super.viewDidLoad()
    self.hideKeyboardWhenTappedAround()
    imagePicker = UIImagePickerController()
    imagePicker.allowsEditing = true
    imagePicker.delegate = self
    scrollView.isScrollEnabled = false
    self.reset()
}

FeedVC.swift:

@objc func signOut(_ sender: AnyObject) {
    KeychainWrapper.standard.removeObject(forKey: "uid")
    do {
        try Auth.auth().signOut()
    } catch let signOutError as NSError {
        print ("Error signing out: %@", signOutError)
    }
    performSegue(withIdentifier: "signOut", sender: nil)
}

Main.storyboard:

enter image description here

signOut Segue:

enter image description here


Solution

  • By the names you have picked, I’m guessing after signout what you really want to do is an unwind segue, basically returning to the original screen. The way you have it set up I believe, you’re actually creating a brand new view controller when you perform the segue from the tableview to the original view when really you want to go back to the one that has already been made.

    What you actually want is an unwind segue, which will actually get you back to the original. This solves the problem mentioned by the other commenter (vicious cycle of segues). https://medium.com/@mimicatcodes/create-unwind-segues-in-swift-3-8793f7d23c6f