我有一個表格填充了一個可變數組。這些單元格是自定義的,具有在customcellclass上委託的UITextView,我希望保留這個值。它在每個表reloadData之後被擦除。維護自定義單元格中的UITextView的值
有關如何保持它的任何想法?我有這個想法,但不能去:
- 將textView值存儲在填充表的同一個數組上。來自哪裏? TextViewDidEndEditing?如何傳遞價值,以及如何知道它是哪一行?
- 維護一個與另一個不同的textViews數組。溝通細胞表的同樣的問題,然後我也必須維護這個數組。另外,我應該將textView從.nib中移開。 ...我不知道更多的知道。
任何方法或幫助將不勝感激。謝謝! PS:我做了大量的搜索,大部分指向表單,但這是一個可變數組,我將在表上有未定義的行。
- (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;
}
對我們的任何代碼,看看?就像-cellForRowAtIndexPath:首先。 –
你在編輯中去了!任何你需要的!謝謝 – g10k