I'm using a custom UITableViewCell that contains a UITextField. I draw this UITableViewCell in a UITableView 5 times with this code:
InputCellTableViewCell *cell = [tableViewIn dequeueReusableCellWithIdentifier:@"inputCell"];
[cell setUp]; //Just sets first responder and delegate.
[cell.textField setPlaceholder:[self.arrayWithFields objectAtIndex:indexPath.row]];
return cell;
When the user have inputed data into the five cells, how do I access each of the cells data o the best way an开发者_开发问答d save it? I do not have a decleration for each cell as you can see.
You can use the tag for your UITextField for each cell
if (indexPath.section == 0) {
// Add a UITextField
UITextField *textField = [[UITextField alloc] init];
// Set a unique tag on each text field
textField.tag = indexPath.row;
[cell.contentView addSubview:textField];
[textField release];
}
if (indexPath.section == 1) {
// Add a UITextField
UITextField *textField = [[UITextField alloc] init];
// Set a unique tag on each text field
textField.tag = indexPath.row;
[cell.contentView addSubview:textField];
[textField release];
}
精彩评论