gpt4 book ai didi

swift - 选择 UITextField 中的所有文本

转载 作者:搜寻专家 更新时间:2023-11-01 06:15:28 25 4
gpt4 key购买 nike

如何以编程方式选择 Swift 文本字段中的所有文本?

喜欢 Safari

enter image description here

我试着喜欢这个:

textField.becomeFirstResponder()

textField.selectedTextRange = textField.textRange(from: textField.beginningOfDocument, to: textField.endOfDocument)

或者这个:

textField.selectAll(self)

但这不是我想要的效果。

最佳答案

如果您的目标只是选择 UITextField 中的所有文本,使用这个:

textField.selectAll(nil)

关于swift - 选择 UITextField 中的所有文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46152705/

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