I have a loginViewController with Password Autofill feature. Everything works as it should except one small detail, which I cannot find a solution to. My conclusion is that there is none, but perhaps I could be wrong.
When the user selects a stored username and password, it autofills. But the keyboard stays open, and the user must dismiss the keyboard and press the log in button.
The documentation Password autofill workflow states that the delegate function:
textField:shouldChangeCharactersInRange:replacementString:
is called, when an quickbar item is pressed. I would like to close the keyboard so that the user can immediately press the log in button, and proceed, after a password is selected. But in this delegate function its not possible since its called whenever the textfields are modified as well.
Is there any solution to do this?
Related
So in a small app I am making, if the user clicks the sign in button, two text fields pop up from the bottom of the screen(the username and the password textfields). Now I want the keyboard to pop up automatically as well when the user clicks on the sign in button. To do this I said:
self.userNameTextField.becomeFirstResponder()
self.passwordTextField.becomeFirstResponder()
Now for some reason I can't click on the userNameTextField. The cursor is always stuck on the passwordTextField. I think this is because it is making the password text field the first responder so it won't let me click on the username one. Is there any other way to automatically bring up the keyboard without using this firstResponder method?
by doing what you described here you are making userNameTextField a first responder, and right after that you are making passwordTextField a first responder - which ends up having passwordTextField set as first responder (because Swift is lightning fast and you can't even notice the moment when userNameTextField becomes a first responder).
So, pick which one will you call (probably self.userNameTextField.becomeFirstResponder() because you want user to type the username first) and then you could call resignFirstResponder() (which will resign userNameTextField from being a first responder when user taps the "Return" on the keyboard) by implementing UITextFieldDelegate method textFieldShouldReturn (let me know if you need some help there) and right after that call self.passwordTextField.becomeFirstResponder() to make your passwordTextField a first responder so that user can type a password.
I have a UITextField with a Clear button. Whenever the user resigns first responder on the textfield, it submits the change to a webservice.
When the user taps the clear button, seemingly, the textfield loses its first responder status, causing the didEndEditing delegate method to be called. So the webservice call is made, with the old, populated value. Then, the textfield is cleared, calling didEndEditing again, calling the webservice again.
Why does this happen this way? I would expect the clear button to empty the text and then call didEndEditing on the delegate so you only get one message.
If you're referring to the built in clear button on the UITextField, when the user taps it that causes the text field to loose focus as the button itself receives the touch - this triggers the first -didEndEditing. Then the release of the clear button causes it to clear the text field, which calls -didEndEditing to fire yet again when the text is actually cleared. Yeah, it is definitely less than ideal.
I have view with a text field, an image and a few buttons.
I want to make sure the keyboard is displayed and is on top when the view is displayed
AND
I want to make sure it doesn't go away after I type something in to the text field and submit it.
I called [txtField becomeFirstResponder] with viewdidload and the keyboard is appearing by default but with a tiny delay after the view is displayed.
Also the becomefirstresponder doesn't help after I have my text field submitted.
Thanks in advance for your help!
Also the becomefirstresponder doesn't help after I have my text field submitted.
That part makes no sense. By default, a text field does not dismiss the keyboard unless you dismiss it with endEditing: or resignFirstResponder. If the keyboard is going away, you must be making it go away. So don't and it won't.
EDIT: And indeed, your comment later reveals the answer: you've hooked up the didEndOnExit control event from the text field. Well, that causes the keyboard to be dismissed when the user presses the Done button! So you are effectively hitting yourself in the face and then complaining that someone is hitting you in the face.
So the solution, obviously, is don't hook up the didEndOnExit control event (to anything). Instead, just give the text field a delegate and use the delegate messages to learn what the user is doing. None of those have any automatic behavior with regard to the keyboard, so the keyboard won't be dismissed automatically. For example, to learn when the user is typing, use textField:shouldChangeCharactersInRange:replacementString:. To learn when the user has hit the Done button, use textFieldShouldReturn:. And so on.
I have a UISwitch that shows the password when it's ON and hides it when it's OFF. When it's clicked, an AlertView pops up asking for a password then confirm. My problem is the switch still switches to display the OFF text instead of it still being ON when the user clicks on it/enters the wrong password. I need it to still read the ON status/text until the user successfully enters the correct password on the alertview.
Step 1
in your interface do this
IBOutlet UISwitch *passwordSwitch;
Step 2
set your switch to the above
Step 3
Upon your logic if the password fails do this
passwordSwitch.on=NO;
Edit:
If it succeed do this
passwordSwitch.on=YES;
This is a bit of a strange error.
I have a log-in screen which accepts a username and password inside two UITableViewCells. When the app first loads, this screen works fine.
It loads another screen which allows a user to log-out - this reloads the original screen and the user is capable of logging in again (or with a different username and password).
If the user logs out again, the original screen presents itself but the UITextFields associated with the username and password will not work. textFieldDidBeginEditing is not called - even though it was successfully called on the previous two attempts.
The "loading screen" .XIB file is loaded fresh each time - so I simply don't understand why the third time would cause problems?
Any suggestions would be greatly appreciated!
Thanks
It is look like timing issue to me. It may happen while changing(transition) the views. Some how your textfield can not be the first responder.
I would check who is the first responder?
Can you try call resignFirstResponder for the view which is responsible for logging out, just before logging out.
Another problem may be you finger does not touch exactly on text field but table view cell.
Did you implement the tableView:didSelectRowAtIndexPath: ?