Getting the Value of a UITextField as keystrokes are entered?

前端 未结 3 1785
醉酒成梦
醉酒成梦 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条回答
  •  Happy的楠姐
    2020-11-30 18:39

    It turns out, the easiest way to do this is using Interface Builder:

    • Add a IBAction (to the ViewController, say, as in this case)
    • Ctrl-Click (or right click) on the UITextField in Interface Builder
    • Connect the "Editing Changed" event to the File's Owner's IBAction added in the first step.

    Works like a charm :) (I can't believe I spent numerous days on this, and to realize now that the solution was much simpler than I'd thought :P)

提交回复
热议问题