我想要一个点击来选择文本,而不是长按来选择文本。
是这样做的吗?
或者用UIGestureRecognizerDelegate来唤醒长时间的记者行动?
谢谢。

最佳答案

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)
}

10-08 06:11