how to perform an action right after user finish inputting data in the textfield?

sarah

I have a UITextField that will be used to input the data of time (10,15,30 minutes etc). I want right after the user manually input the minute data, then I will check, if it is more than zero or not ( negative or zero is not allowed), if the value is below 1 then I will show the alert.

I have tried to use the code below, but it doesn't work :

func textFieldShouldEndEditing(_ textField: UITextField) -> Bool {
    if textField == numberReminderTextField {
        let valueNumber = Int(numberReminderTextField.text ?? "0") ?? 0
        if valueNumber < 1 {
            showAlert(alertTitle: "Sorry", alertMessage: "The number you input is invalid, please input the number that more than zero.", actionTitle: "Back")
        }
    }
    return false
}
KTang

In my opinion, you shouldn't do this checking in textFieldShouldEndEditing. You can do the checking in textFieldDidEndEditing or set your custom observer on .editingChanged control event.

I.E.

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

If the alert still not show up, you should look into your showAlert function.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Android - Unable to destroy activity after finish, caused by IllegalStateException: Can not perform this action after onSaveInstanceState

From Dev

How to perform action after JFrame is closed?

From Dev

How to perform action after UIActivityViewController called and then closed

From Dev

Why action is perform multiple time after loading is finish and why it queuing all the events?

From Java

Alert user before leaving page after inputting some data (Specially in ReactJS)

From Dev

How to dismiss keyboard on a textfield when a user triggers an action sheet and dismisses it?

From Dev

How to get value from a text field when user finish typing or goes out of textfield using jQuery?

From Dev

How to Show a UIAlertController and Perform an Action when User clicks OK?

From Dev

How to perform some action when a user pushes to a remote git repo

From Dev

How to Perform an Action Based on User's Selection on Dialog Fragment List

From Dev

How to Show a UIAlertController and Perform an Action when User clicks OK?

From Dev

How to perform action when user click on myLocation button in Objective C?

From Dev

Inputting DatePicker in TextField problems

From Dev

How to perform an action exactly after 0.3 seconds for a given number of times?

From Dev

How to open another app without "Can not perform this action after onSaveInstanceState"?

From Dev

How to perform some action on a node after it is loaded in JavaScript in Odoo?

From Dev

How to add a tabbar after a user action

From Dev

Perform Action after the Binding Is Complete

From Dev

perform action after time react

From Dev

Perform action after if statement CasperJS

From Dev

Perform action AFTER subscribing to observable

From Dev

Doing an action after UIView beginAnimations is finish

From Dev

How to create textfield with pre text that continue appear after user input

From Dev

the "done" message after a &-command is not displayed right away, but after a user action. Why?

From Dev

How to perform right shift on RISC

From Dev

Calendar User inputting dates?

From Dev

PayPal Adaptive Payments - User is not allowed to perform this action

From Dev

PayPal Adaptive Payments - User is not allowed to perform this action

From Dev

User input box to pick column to perform action

Related Related

  1. 1

    Android - Unable to destroy activity after finish, caused by IllegalStateException: Can not perform this action after onSaveInstanceState

  2. 2

    How to perform action after JFrame is closed?

  3. 3

    How to perform action after UIActivityViewController called and then closed

  4. 4

    Why action is perform multiple time after loading is finish and why it queuing all the events?

  5. 5

    Alert user before leaving page after inputting some data (Specially in ReactJS)

  6. 6

    How to dismiss keyboard on a textfield when a user triggers an action sheet and dismisses it?

  7. 7

    How to get value from a text field when user finish typing or goes out of textfield using jQuery?

  8. 8

    How to Show a UIAlertController and Perform an Action when User clicks OK?

  9. 9

    How to perform some action when a user pushes to a remote git repo

  10. 10

    How to Perform an Action Based on User's Selection on Dialog Fragment List

  11. 11

    How to Show a UIAlertController and Perform an Action when User clicks OK?

  12. 12

    How to perform action when user click on myLocation button in Objective C?

  13. 13

    Inputting DatePicker in TextField problems

  14. 14

    How to perform an action exactly after 0.3 seconds for a given number of times?

  15. 15

    How to open another app without "Can not perform this action after onSaveInstanceState"?

  16. 16

    How to perform some action on a node after it is loaded in JavaScript in Odoo?

  17. 17

    How to add a tabbar after a user action

  18. 18

    Perform Action after the Binding Is Complete

  19. 19

    perform action after time react

  20. 20

    Perform action after if statement CasperJS

  21. 21

    Perform action AFTER subscribing to observable

  22. 22

    Doing an action after UIView beginAnimations is finish

  23. 23

    How to create textfield with pre text that continue appear after user input

  24. 24

    the "done" message after a &-command is not displayed right away, but after a user action. Why?

  25. 25

    How to perform right shift on RISC

  26. 26

    Calendar User inputting dates?

  27. 27

    PayPal Adaptive Payments - User is not allowed to perform this action

  28. 28

    PayPal Adaptive Payments - User is not allowed to perform this action

  29. 29

    User input box to pick column to perform action

HotTag

Archive