ios - 快速正确使用 UITextField

标签 ios swift uibutton uitextfield

我有一个应用程序,其中标签 - 文本字段。许多用户单击标签并希望他们将编辑 UITextField。这个问题的正确实现是什么?我是否应该创建一个按钮来注册触摸并可编程单击文本字段? 我该如何存档?

enter image description here

最佳答案

  1. 设置 label.userInteractionEnabled = true
  2. label.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "tapFunc"))
  3. 在您的 tapFunc 中:textField.becomeFirstResponder

关于ios - 快速正确使用 UITextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34810978/

相关文章:

ios - PushViewController 崩溃

iOS JSON 请求

ios - AVCaptureDevice videoZoomFactor 捏合缩放率

swift - UIButton 的 CollectionView 问题

iphone - 当 UIButton 状态改变时执行操作

ios - 带有 uibutton.addTarget 到 UIView 的 Swift 类不起作用

ios - NSURLCache 不起作用(使用 Cache-Control = no-cache)

ios - OCMClassMock 和 OCMStrictClassMock

ios - 转换为 swift 3.0 时,UIButton 上 'dismiss()' 的使用不明确

arrays - Swift - 从文件读取/写入数组数组