Search code examples
iosswiftxcode6.3

touchesBegan not being called sometimes


I have touchesBegan in my initial Login ViewController to dismiss the keyboard and cancel a custom AlertView. Though it works initially, touchesBegan is not being called after I logout with performSegueWithIdentifier.

//to resign keyboard
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
        println("touchesBegan");
        self.view.endEditing(true)
       loginAlert.hideView()
       signupAlert.hideView()
}

//Logout
self.performSegueWithIdentifier("gotoLoginSegue", sender: self);

Solution

  • The issue was because i used both UITapGestureRecognizer and touchesBegan. I handled the scenario in UITapGestureRecognizer and removed the touchesBegan logic and it fix