dhemery / victor

A Java driver for iOS applications
MIT License
11 stars 4 forks source link

Clearing an TextField. #16

Open Trilokesh opened 11 years ago

Trilokesh commented 11 years ago

hi Dale, using victor how can we clear an edit field.

I am seeing an TextSearchBar. Now need to clear the whatever text I had entered previously. Could you please help how can I achieve that.

Thanks, Lokesh

dhemery commented 11 years ago

Does the search bar have a "clear" button? If so, my inclination would be to click that.

Lacking a clear button, what I've done is to add a category to UITextField with some methods to safely set, insert, and append text. Here's the code, from my Victor demo app: https://github.com/dhemery/vigor/tree/master/vigor/categories

All of the methods end up calling the nasty-looking DFX_replaceTextAtLocation method in the middle of the .m file. That method not only sets the text field, but also (to the best of my understanding) requests the same permissions and validations that iOS would request, and sends the same notifications that iOS would send. Be aware that my understanding may be incomplete or obsolete.

Frank may now offer a built-in, cleaner way to clear text. Consider asking on the Frank mailing list: https://groups.google.com/forum/?fromgroups#!forum/frank-discuss