[英]UITextField becomeFirstResponder works only once
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. 将UITextField添加到视图中,并调用beginFirstResponder。 In the textFieldShouldReturn method, resignFirstResponder is called.
在textFieldShouldReturn方法中,调用了resignFirstResponder。 Then in textFieldShouldEndEditing, the UITextField is removed from the view.
然后在textFieldShouldEndEditing中,将UITextField从视图中删除。
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. 一切正常,但是问题在于,当用户再次尝试输入其名称时,会显示UITextField,但不会显示键盘。
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
谢谢
尝试在textFieldDidEndEditing中进行工作,当您第二次点击文本字段时,控件应进入textFieldShouldBeginEditing中,尝试检查是否有断点,否则不会出现问题,那就是您的文本字段没有分配任何内存,如果有进入此功能时,将此文本字段设置为第一响应者。
如果为该UITextField设置了属性,请确保在将其从视图中删除后将其设置为nil。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.