Matt Butler Matt Butler - 3 months ago 12
Swift Question

Cannot select textfield with single tap (Swift)

I have two UITextFields inside of a custom UITableView cell. Selecting the first textfield works just fine, and the keyboard appears as it should. However, while one of the textfields is selected, if you try and tap on another textfield, the keyboard continues to show but the textfield won't register keyboard typing input.

I have tried for hours with no luck in getting this to work. After a second tap on the 2nd textfield, it finally focuses and all is fine. Any solutions?

enter image description here

Answer

I had the same Problem with some touch events - try to force iOS to run on the main Thread:

dispatch_async(dispatch_get_main_queue(),{
   self.yourTextField.becomeFirstResponder()
})
Comments