I have a table populated with a mutable array. The cells are custom, with an UITextView, delegated on the customcellclass, which value I'd like to keep. It gets erased after every table reloadData.
Any idea about how to keep it? The ideas I had, and not able to go for:
- Store the textView value on the same array which populates the table. From where? TextViewDidEndEditing? How to pass the value, and how to know which row was it?
- Maintain an array of textViews apart from the other. Same problem of communicating cell-table and then I have to maintain this array also. Besides, I should take the textView away from the .nib. ...I don't came up with more know.
Any approach or help will be much appreciated. Thank you!
PS: I did lots of searches, most directing to forms, but this is a mutable array, I'll have undefined rows on the table.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
GuiCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray* views = [[NSBundle mainBundle] loadNibNamed:@"GuiCustomCell" owner:nil options:nil];
for (UIView *view in views) {
if([view isKindOfClass:[UITableViewCell class]])
{
cell = (GuiCustomCell*)view;
}
}
}
if (timesArray || [timesArray count]) {
TakenTime *time = [[TakenTime alloc] init];
time = [timesArray objectAtIndex:indexPath.row];
if ([timeFormat isEqualToString:@"seconds"]) {
cell.detailTextLabel.text = [time stringTimeFormat2];
} else {
cell.detailTextLabel.text = [time stringTimeFormat1];
}
cell.detailTextLabel.font = [UIFont systemFontOfSize:25];
cell.textLabel.font = [UIFont systemFontOfSize:18];
cell.textLabel.textAlignment = UITextAlignmentLeft;
cell.detailTextLabel.textAlignment = UITextAlignmentCenter;
cell.textLabel.text = [NSString stringWithFormat:@"%i.",indexPath.row+1];
}else{
cell.textLabel.text = @" ";
}
[cell setDefaultText:TRUE];
return cell;
}