ios - Refer to a particular UITextField inside a particular UITableViewCell -
i have uitableview
created programatically, , have written code programmatically create uitextfield
on each , every cell.
when user taps on text field, picker appears , user can select item picker, , after selection made, selection should displayed in text field of particular cell.
now problem facing is, whenever tap on text field of table view cells, picker appears correctly, after item picked picker, value gets stored in text field of last table view cell. why happen?
could please explain me how refer particular text field can perform action on particular text field?
create subclass of uitableviewcell
, , use cells. add property reference text field:
@interface yourtableviewcell : uitableviewcell @property (strong) uitextfield *textfield; @end
then, assign text view cell when create it:
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cellidentifier"; yourtableview *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (!cell) { cell = ... // create cell here uitextfield *textfield = ... // create text field here cell.textfield = textfield; // assign text field cell } return cell; }
once have done this, text field linked cell in, can text view cell , set value.
Comments
Post a Comment