问题
In my app, there is the ability for the user to input their name.
A UITextField is added to the view and becomeFirstResponder is called. In the textFieldShouldReturn method, resignFirstResponder is called. Then in textFieldShouldEndEditing, the UITextField is removed from the view.
This all works fine, but the problem is that when the user tries to input their name a second time, the UITextField shows but keyboard does not.
I have tried lots of things, like moving around become/resign firstresponder or retaining/not retaining the textfield, but I just cant seem to get it to work. Any ideas? Thanks
回答1:
If you have a property set for that UITextField, make sure to set it to nil after removing it from the view.
回答2:
try doing the work in textFieldDidEndEditing, and when you tap on text field second time, control should go in textFieldShouldBeginEditing, try checking that with break points, it it does not goes then problem is that your textfield does not have any memory allocated and if it goes in this function set this textfield as first responder.
来源:https://stackoverflow.com/questions/9711929/uitextfield-becomefirstresponder-works-only-once