gpt4 book ai didi

ios - 如何在 swift ios 中自动将光标从一个文本字段移动到另一个文本字段?

转载 作者:行者123 更新时间:2023-11-28 12:54:45 25 4
gpt4 key购买 nike

    func textFieldDidBeginEditing(textField: UITextField) {
scrlView.setContentOffset(CGPointMake(0, textField.frame.origin.y-70), animated: true)
}

func textFieldShouldReturn(textField: UITextField) -> Bool {


textField.resignFirstResponder()

scrlView .setContentOffset(CGPointMake(0, 0), animated: true)

return true
}

如何在第一个文本字段中输入值后自动将光标从一个文本字段移动到另一个文本字段?

最佳答案

首先,您需要按顺序向您的文本字段添加标签

func textFieldShouldReturn(textField: UITextField) -> Bool {

let nextTag = textField.tag + 1;
// Try to find next responder
var nextResponderTxt: UITextField!
nextResponderTxt = textField.superview?.viewWithTag(nextTag) as? UITextField
if ((nextResponderTxt) != nil) {
// Found next responder, so set it.
nextResponderTxt.becomeFirstResponder()
} else {
// Not found, so remove keyboard.
textField.resignFirstResponder()
}
return false; // We do not want UITextField to insert line-breaks.
}

也可以把返回键改成next

enter image description here

关于ios - 如何在 swift ios 中自动将光标从一个文本字段移动到另一个文本字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35316931/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com