ペン先からロードされたカスタム UITableViewCell があります。次の手順を実行することで、reuseIdentifier を使用してこれをアプリに取り込むことができます。
1) Nib の再利用識別子を「CustomCellIndentifier」として設定します。
2) nib を登録します。
[[self tableView] registerNib:[UINib nibWithNibName:@"CustomCell" bundle:nil] forCellReuseIdentifier:@"CustomCellIndentifier"];
3) tableview:cellForRowAtIndexPath のセルを返します
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CustomCellIndentifier"];
return cell;
}
私の質問は、再利用識別子なしでセルを返すにはどうすればよいですか? 小さなテーブルがあり、セルを再利用したくありません (スクロールすると、セルにあるサブビューが台無しになります)。
上記の 3 つの再利用識別子を nil に設定して組み合わせてみましたが、すべてエラーが発生します。
以下でもこれを試しましたが、セルをスクロールするとセルの内容がリセットされ、「再利用されているテーブルセルのインデックスパスがありません」というエラーメッセージが表示されます。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
cell = [topLevelObjects objectAtIndex:0];
}
return cell;
}