Getting the Value of a UITextField as keystrokes are entered?

前端 未结 3 1789
醉酒成梦
醉酒成梦 2020-11-30 18:13

Let\'s say I have the following code:

IBOutlet UITextField* nameTextField;
IBOutlet UILabel* greetingLabel;

I\'d like the greetingLab

3条回答
  •  误落风尘
    2020-11-30 18:24

    UITextField has a notification UITextFieldTextDidChange which will be fired every time the text changes if you register for it. Just register for that notification and in the method called by the notification, change the label's text.

    To add to this, the object passed to your notification handler will have the text of the UITextField.

    Hope that helps.

提交回复
热议问题