iphone - How to access UITextField in UITableView through tag in several functions -
i have several uitextfield in uitableview. have assigned different tags fields problem facing accessing uitextfield several other functions.
how access them? here code:-
uitextfield *textfield = (uitextfield *)[self.view viewwithtag:0];
can help?
i have same feature in 1 of apps , used below code accomplish , never had kind of problem.
first of need store textfield value temporary in array. make array this.
arrtemp=[[nsmutablearray alloc]initwithobjects:[nsstring stringwithformat:@""], [nsstring stringwithformat:@""], [nsstring stringwithformat:@""], [nsstring stringwithformat:@""], [nsstring stringwithformat:@""], [nsstring stringwithformat:@""], [nsstring stringwithformat:@""], [nsstring stringwithformat:@""], [nsstring stringwithformat:@""],nil];
then give textfield tag = indexpath.row;
after need replace textfield value in below 2 methods.
-(bool)textfieldshouldreturn:(uitextfield *)textfield{ [arrtemp replaceobjectatindex:textfield.tag withobject:textfield.text]; } -(void)textfielddidendediting:(uitextfield *)textfield{ [arrtemp replaceobjectatindex:textfield.tag withobject:textfield.text]; }
at last need set value in cellforrowatindexpath datasource method. whenever user scroll tableview set previous value temp array. this.
cell.txtentry.text = [arrtemp objectatindex:indexpath.row];
Comments
Post a Comment