MainViewController に UITableView があります。ユーザーがセルをタップすると、
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
selectedRow = indexPath;
....
[self performSegueWithIdentifier:@"OtherViewControllerSegue" sender:self];
}
それらは別の UIViewController に移動されます (OtherViewController と呼びましょう)。OtherViewController には、選択したセルの名前が設定されます。OtherViewController が閉じられると、MainViewController のセルが新しい名前で更新されます。
[[[mainvc.myTableView cellForRowAtIndexPath:mainvc.selectedRow] textLabel] setText:namecell.textField.text];
[self.navigationController popViewControllerAnimated:YES];
画面に収まるよりも多くのセルが表示されるまで、これはすべて正常に機能します。画面に収まりきらない数のセル (iPhone の場合は 8、iPad の場合は 16) がある場合、8 番目または 16 番目のセルごとに名前が設定されます。私が間違っていることについてのアイデアはありますか?
アップデート:
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [pointsTableView dequeueReusableCellWithIdentifier:@"myTableCell"];
return cell;
}