ios - UIprogressView Status based on text entered on UITextfield -


i progress uiprogressview status based on text entered in uitextfield.

if entered 3 letters, should 25%, , if 5 letters should 50% , on

the simplest solution use textfielddidchangemethod.
since uitextfielddelegate don't have that, can add behavior of uitextfield (or subclassed textfield matter) with:

[yourtextfield addtarget:self                    action:@selector(textfielddidchange)          forcontrolevents:uicontroleventeditingchanged]; 

and in target method:

- (void) textfielddidchange {     float txtprogress = yourtextfield.text.length / 10.0;     [yourprogressview setprogress:txtprogress animated:yes]; } 

edit : can use uitextfieldtextdidchangenotification controlevent.
both seem work fine.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -