Check for changes in UITextField

后端 未结 1 1192
[愿得一人]
[愿得一人] 2020-12-12 06:57

I\'m attempting to make an app that checks the text in a UITextField and does something in response to what is written in it. I could possibly have the user type their input

相关标签:
1条回答
  • 2020-12-12 07:08

    What you have to do is to attach an IBAction to your UITextField Sent Events Editing Changed:

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

    enter image description here

    enter image description here

    0 讨论(0)
提交回复
热议问题