I have a ViewController with 2 UITextField elements: Login and Password. I set a delegate for these fields, which includes the following code:
func textFieldShouldReturn(textField: UITextField) -> Bool { if textField === self.loginField { self.loginField.resignFirstResponder() self.passwordField.becomeFirstResponder() return false } return true }
This logic should switch the user from the text input field to the password when he clicks the "Next" button on the keyboard. But I'm stuck with a glitch: after
self.passwordField.becomeFirstResponder()
the text in the input field moves to the upper left corner and back. And what is more strange: this glitch is reproduced only for the first time, then you need to recreate the ViewController to observe this behavior
Here is a video with a glitch http://tinypic.com/player.php?v=6nsemw%3E&s=8#.VgVb3cuqpHx
I ended up with this:
func textFieldShouldReturn(textField: UITextField) -> Bool { if textField === self.loginField { self.loginField.resignFirstResponder() // Shitty workaround. Hi, Apple! self.loginField.setNeedsLayout() self.loginField.layoutIfNeeded() self.passwordField.becomeFirstResponder() return false } return true }
ios uitextfield swift
user3237732 Sep 24 '15 at 15:32 2015-09-24 15:32
source share