如何通过点击并按住事件复制 UITextField?
我有几个 UITextFields 设置可以在屏幕上移动,并且可以通过双击进行编辑。我想知道是否有办法点击并按住 UITextField 来复制它?
I have several UITextFields setup to move around the screen and are editable with a double tap. I was wondering if there was a way to tap and hold the UITextField to copy it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过在文本字段上长按手势?您可以从中复制文本,但我不确定文本选择。
下面的代码是用长按手势注册文本字段。
然后识别长按时的回调函数:
试试这个。
Did you try long press gesture on the text field? You can copy the text from it, though I am not sure of the text selection.
The below code is to register textfield with the long press gesture.
Then callback function when the long press is recognized:
Try this out.
设置一个 UILongPressGestureRecognizer: 并查看 textFieldShouldBeginEditing: 是否也被触发?如果是,那么您只需复制其中的文本字段即可。我不知道是否会触发或者手势识别器是否会“超越”它?
set up a UILongPressGestureRecognizer: and see if textFieldShouldBeginEditing: is fired also? if it is, then you can just copy the text field in there. i have no idea if will fire or if the gesture recognizer would "over ride" it?