DETECTING VALUE CHANGED IN UITEXTFIELD

Steven Hill

Total Post:10

Points:72
Posted by  Steven Hill
 871  View(s)
Ratings:
Rate this:

I was creating an iPhone app and having a situation when I need to detect if the text field value is changed every time. The UITextFieldDelegate method shouldChangeCharactersInRange works but it’s not fully useful for me because it returns YES, so the texts of textField are not being available to other methods.

I want something like Java textChanged event handler, can anyone help me.

  1. Tarun Kumar

    Post:214

    Points:1642
    Re: Detecting value changed in UITextField

    Yes, your problem is thinkable but I have a solution for your problem. For the text field control add a notificationMethod “textFieldDidChange”.
    For example:

    [textField addTarget:self
                      action:@selector(textFieldDidChange:)
                      forControlEvents:UIControlEventEditingChanged];

    Now, the textFieldDidChange: method will be called whenever you will change any value and also it can reload your table view as needed.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!