Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application freezes after editing custom UITextField

I have a custom UITextField used for validating for non empty input, correct emails, passwords bigger than x characters etc.

The UITextField has a delegate to itself, since I do all the validation on the text field object itself. Not sure if this is the problem.

This custom UITextField is created in the .XIB file.

The text field sometimes locks the application when editing the text field itself. It also usually locks up when I press the "Next" button on the keyboard (for going to the next text field that needs to be filled).

Xcode doesn't give back an error (such as a loop-error, which I was assuming it was), the application just locks up. This doesn't happen all the time, but usually, if I stress test it with text, then press "Next", it's likely to lock up.

The app doesn't crash...it doesn't go back to the main screen, but it really just locks up, and stays unresponsive.

Any ideas? Let me know if you need more info to figure this out. I'm at a loss at the moment.


edit: Solved, apparently it's not a good idea to set a UITextField's delegate to itself. What I ended up doing is creating a separate class that deals specifically as being the delegate for the UITextField and doing all the logic in that class. That class would also have a property connected to the text field it is a delegate for.

like image 915
Alex Avatar asked Feb 11 '13 15:02

Alex


1 Answers

I'll also write the answer here:

Apparently it's not a good idea to set a UITextField's delegate to itself, because it can end up going into a loop.

What I ended up doing is creating a separate class that deals specifically as being the delegate for the UITextField and doing all the logic in that class. That class would also have a property connected to the text field it is a delegate for.

like image 120
Alex Avatar answered Sep 20 '22 20:09

Alex