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
Post a Comment