【问题标题】:Check for changes in UITextField检查 UITextField 中的更改
【发布时间】:2015-03-14 03:36:06
【问题描述】:

我正在尝试制作一个应用程序来检查 UITextField 中的文本并根据其中写入的内容执行某些操作。我可以让用户输入他们的输入,然后按下一个按钮。我希望能够不断检查文本字段,而不会让应用程序无响应。

【问题讨论】:

  • UITextLabel??你是说 UILabel 还是 UITextField?
  • 我同意@rdelmar,这个问题不清楚。

标签: ios swift uitextfield


【解决方案1】:

您要做的就是将 IBAction 附加到您的 UITextField 发送事件编辑更改:

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var strLabel: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    @IBAction func editingChanged(sender: UITextField) {
        strLabel.text = sender.text
    }
}

【讨论】:

    猜你喜欢
    • 2015-04-08
    • 2013-03-07
    • 2015-01-15
    • 1970-01-01
    • 2012-12-06
    • 1970-01-01
    • 1970-01-01
    • 2023-03-18
    相关资源
    最近更新 更多