コードをif (cell == nil)
ブロックから削除しないでください。代わりに、作成しているセルの代表的な識別子を作成します。セルの内容のすべてが識別子で参照されていることを確認してください。たとえば、3つの数字が表示されている場合は、そのようなコンテンツを持つセルのみを参照するユニークな方法で、識別子に3つの数字を指定してください。
クラスに3つのNSArrayプロパティ、array1、array2、およびarray3があり、NSNumberオブジェクトの内側にint値がラップされているとします。あなたがのUITableViewを埋めるために、これらのNSArraysを使用したい、これは私がしたいものです。
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *identifier = [NSString stringWithFormat:@"%@-%@-%@",
[[array1 objectAtIndex:indexPath.row] intValue],
[[array2 objectAtIndex:indexPath.row] intValue],
[[array3 objectAtIndex:indexPath.row] intValue]];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:identifier] autorelease];
//Build your cell here.
}
return cell;
}
時間を節約できました。ありがとうございました!私はこの愚かな間違いを推測していないだろう:) – Pruthvid
私のソリューションは他の誰かを助けることができてうれしい! –