可変配列が設定されたテーブルがあります。セルはカスタムで、UITextViewがあり、customcellclassに委任されています。この値は、保持したいと思います。テーブルをreloadDataするたびに消去されます。
それを維持する方法について何か考えはありますか?私が持っていた、そして行くことができなかったアイデア:
- textView値は、テーブルに入力されているのと同じ配列に格納します。どこから?TextViewDidEndEditing?値を渡す方法と、それがどの行であったかを知る方法は?
- textViewの配列を他の配列とは別に維持します。セルテーブルの通信に関する同じ問題があり、この配列も維持する必要があります。さらに、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;
}