我希望只需点击一下即可选择文字,而不是长按以选择文字。
这是一种方法吗?
或使用UIGestureRecognizerDelegate
唤醒长按动作?
感谢。
答案 0 :(得分:0)
let singleTap = UITapGestureRecognizer(target: self, action:#selector(self.singleTapAction(_:)))
singleTap.numberOfTapsRequired = 1
view.addGestureRecognizer(singleTap)
func singleTapAction() {
textField.becomeFirstResponder()
textField.selectedTextRange = textField.textRange(from: textField.beginningOfDocument, to: textField.endOfDocument)
}