[英]How to move one text field to another using keyboard return key in swift3 ios
I doubt if you can do that with the 'Done' button, but you may achieve that with the return key by我怀疑您是否可以使用“完成”按钮来做到这一点,但是您可以使用返回键来实现
Make your class a UITextField Delegate让你的班级成为 UITextField 委托
class VC: UIVIewController, UITextFieldDelegate
In your ViewDidLoad method do this -在您的 ViewDidLoad 方法中执行此操作 -
textField1.becomeFirstResponder()
So that when user comes in this screen the 1st textfield will directly become active(not the right word but using this word for lack of better alternative)因此,当用户进入此屏幕时,第一个文本字段将直接变为活动状态(不是正确的词,但由于缺少更好的选择而使用此词)
And when you need it to move to the next textfield when he presses return,当你需要它在他按下回车键时移动到下一个文本框时,
func textFieldShouldReturn(textField: UITextField) -> Bool { textField1.resignFirstResponder() if (textField == textField1){ textField2.becomeFirstResponder() } else if (textField == textField2){ textField3.becomeFirstResponder() } return true }
You may use a switch case too in the above delegate method.您也可以在上述委托方法中使用 switch case。 And as mentioned in the comment in the question, do go through the link and know how to properly ask questions, giving as much detail as possible.
正如问题中的评论中所提到的,一定要浏览链接并知道如何正确提问,并提供尽可能多的细节。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.