0

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);
Andy McSherry
  • 4,676
  • 3
  • 26
  • 36
Dinesh Jeyasankar
  • 1,043
  • 3
  • 10
  • 24
  • Is the problem that it doesn't work on returning to the view with the login statement or is it not working on a different view? The latter is obvious because of you don't listen for touches in each view controller it simply won't work – Allison Apr 14 '15 at 01:40
  • Its not working on the same view. I have the touchesBegan in Login View. It works initially. After login it moves to a different view. Then i logout using the logout statement from that view and return to the same login view. This time touchesBegan is not working. – Dinesh Jeyasankar Apr 14 '15 at 01:43
  • Do you start listing on view did load AND dealloc it (do you do that in swft? I don't use it)? Also, add a log statement in the view did load just to make sure it actually fires. If it doesn't fire you've got an entirely different problem on your hands – Allison Apr 14 '15 at 01:48
  • viewDidLoad loads fine. I am not doing any dealloc in swift. – Dinesh Jeyasankar Apr 14 '15 at 02:09
  • Do you have a gesture recognizer eating the touches? – i_am_jorf Apr 15 '15 at 22:23
  • That helped a lot, i had a UITapGestureRecognizer eating the touches. – Dinesh Jeyasankar Apr 29 '15 at 20:19

1 Answers1

0

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

Dinesh Jeyasankar
  • 1,043
  • 3
  • 10
  • 24