I've searched everywhere and can't seem to find a clear answer on updating a label in real-time.
How do i go about updating a UILabel
(real-time) without the use of a button. For example, i have a text field and a UIlabel
connected to the view controller
.
As soon as the user starts typing in the textfield
, the same text is being displayed in real time on the UI label. As a result,this eliminates the use of a button to update the label. How do i go about doing this?
Use the delegate method:
step 1:Extend class to UITextFieldDelegate
Step 2: Add Following code into ViewDidLoad()
step 3: Make new Function as below:
Here lblDemo is UILabel outlet and txtDemo is UITextField outlet
You are update your label in textField
shouldChangeCharactersInRange
Delegate method :option 1: Directly you can make action of textfield with value changed
option 2: Give Delegate to TextField