I have a uitableivew made up of custom tablecells (of type FormCell). Each cell has a label and textfield.
I would like to iterate all the values to get user input (in other words, what is written in the uitextfields)
I have gotten as far as
开发者_StackOverflow中文版NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"FormCell" owner:self options:nil];
for (id oneObject in nib)
if ([oneObject isKindOfClass:[FormCell class]]) {
}
so i've got the cells but can anyone let me know what to do next please?
thanks!
You should have a Model Object / Collection that you use to keep the values that you get / set in your text fields.
Don't forget that as cells get dequeued you will have to reset the text in each textfield (as it's re-created in your tableView:cellForRowAtIndexPath: to make sure it doesn't disappear when the user scrolls.
Steps: 1. initialise an NSMutableArray (e.g. textFieldValues) 2. in tableView:cellForRowAtIndexPath: create your cell. Set the textField text to be what you have in your collection to be your [textFieldValues objectAtIndex:indexPath.row] 3. Make sure you set a textField delegate (self ?) 4. When the textField finishesEditing save the value in your textFieldValues array. To know which row was edited you can set the tag property of the TextField to be indexPath.row :)
Done.
精彩评论