Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
276 views
in Technique[技术] by (71.8m points)

ios - Check for changes in UITextField

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 and then press a button. I want to be able to check the text field constantly without the application becoming unresponsive.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...