[Swift] Get the timing when the value of textField is changed

I want to get the timing to update the value of textField ... The textView has a method textViewDidChange (_ :) that is called every time the value is updated, but the textField doesn't. You have to implement it yourself

Implementation

Describe the following in viewDidLoad. Now, textFieldDidChange will be called every time the value changes.


textField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)

After that, write textFieldDidChange and finish. When using #selector, add @objc at the beginning of the method


    @objc func textFieldDidChange(sender: UITextField) {
        //Arbitrary processing
    }   

reference

https://stackoverflow.com/questions/28394933/how-do-i-check-when-a-uitextfield-changes

Recommended Posts

[Swift] Get the timing when the value of textField is changed
[Swift] Get the height of Safe Area
Upcast (Java) that can reduce the amount of change when the specification is changed
[Swift] Get the number of steps with CMP edometer
When the hover of Eclipse is hard to see
[Java] How to get the maximum value of HashMap
When the month of the date is acquired, the January shift
[Swift] This is the solution! Illustration of Delegate implementation
Find the approximate value of log (1 + x) in Swift
[Swift] How to get the document ID of Firebase
How is the next value of the Time object correct?
[Swift] Setting the behavior when the Share button is pressed
When is the default value automatically entered without explicit initialization?
Determine that the value is a multiple of 〇 in Ruby
[Rails 6] The save timing of active_strage images has been changed.
The idea of cutting off when the error is not resolved
[Swift5] How to get an array and the complement of arrays
How to output the value when there is an array in the array
[Swift UI] How to get the startup status of the application [iOS]
[Swift] The color of the Navigation Bar is different (lighter) from the specified color.
Investigation method when the CPU of the server running java is heavy
'% 02d' What is the percentage of% 2?
[Swift] Change the textColor of UIDatePicker
The basic basis of Swift dialogs
Incident (rails) that is logged out when user editing of the application
[Swift] How to pass the Label value in the selected collectionViewCell to the destination TextField
When the appearance of the input form is broken on the page after rendering
Error when the member of Entity class used in SpringWebFlux is final
[Java small story] Monitor when a value is added to the List
[Swift] Rather, it is meaningful to avoid var and declare it with let only when there is a branch in the assignment of the initial value.
Get the value of enum saved in DB by Rails with attribute_before_type_cast
When the bean class name is duplicated
Get the result of POST in Java
What is testing? ・ About the importance of testing
[Java] Get the day of the specific day of the week
[Swift] Vaguely grasp the flow of Delegate
Samshin on the value of the hidden field
[Swift] Termination of the program by assertion
When UITextView is not displayed (Swift, Xcode)
[Swift] Change the color of SCN Node
The basic basis of Swift custom cells
[Swift] How to get the number of elements in an array (super basic)
I want to get the value of Cell transparently regardless of CellType (Apache POI)
What I tried when I wanted to get all the fields of a bean
[Ruby] Meaning of &. How to avoid the error when the receiver (object) is nil
Crash when deleting Realm data listed by swift: Index 1 is out of bounds
Pay attention to the boundary check of the input value when using the float type
I managed to get a blank when I brought the contents of Beans to the textarea