简体   繁体   English

UITextField成为firstResponder仅工作一次

[英]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.

相关问题 UITextField成为FirstResponder和重叠子视图 - UITextField becomeFirstResponder and overlap subviews 当UITextField成为FirstResponder时得到通知 - get notified when UITextField becomeFirstResponder UITextField成为FirstResponder,但键盘未显示 - UITextField becomeFirstResponder but the keyboard doesn't showed NSURLConnection只工作一次 - NSURLConnection only works once 按键触摸只工作一次 - Button Touch Only Works Once UITextField如何调用viewDidAppear中的成为firstResponder来减慢当前动画的播放速度? - How come UITextField calling becomeFirstResponder in viewDidAppear slows down the present animation? 如果嵌入到UINavigationController中,则在调用成为firstResponder并设置文本时,UITextField中缺少文本 - Missing text in UITextField while calling becomeFirstResponder and setting text, if embedded in UINavigationController 尝试在编辑时使带有UITextField的自定义UITableViewCell成为FirstResponder - Trying to make a Custom UITableViewCell with a UITextField becomeFirstResponder when Editing 为什么UITextField成为firstResponder在我的子viewcontroller中不显示键盘? - why UITextField becomeFirstResponder doesn't show keyboard in my child viewcontroller? becomeFirstResponder在viewDidAppear中工作,但在viewDidLoad中不起作用 - becomeFirstResponder works in viewDidAppear but doesn't work in viewDidLoad
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM