私は現在次のようにデキューしている3つのカスタム UITableViewCells を持つ UITableView を持っています:
if (indexPath.row == 0) {
static NSString *CellIdentifier = @"MyCell1";
MyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[MyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
return cell;
}
if (indexPath.row == 1) {
static NSString *CellIdentifier = @"MyCell2";
MyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[MyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
return cell;
}
if (indexPath.row == 2) {
static NSString *CellIdentifier = @"MyCell3";
MyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[MyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
return cell;
}
これを複数の方法で実行しようとしましたが、問題は、tableView をスクロールすると、最初のセルが 3 番目のセルの場所に表示され、その逆の場合もあります。奇妙なキャッシングが行われているようです。
誰かが理由を知っていますか?ありがとう。