私はIBで設計された単純なセルを持ち、reuseIdentifierが設定されています。以下のコードはとてもうまく動作します。しかし、NSLog()は結果が決してキャッシュされないことを示します。dequeueReusableCellWithIdentifier:識別子がloadNibNamedセルを取得しない
テーブルビューコントローラクラス:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
switch/case for various cell types
{
Foo * item = [results objectAtIndex:indexPath.row];
return [MyCell tableView:tableView populatedCellWith:item];
}
}
MyCellクラス..
+(UITableViewCell *)tableView:(UITableView *)tableView populatedCellWith:(Foo *)item
{
static NSString * identifier = @"XXX";
MyCell *cell = (MyCell *) [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
NSArray * items = [[NSBundle mainBundle] loadNibNamed:@"MyCell"
owner:self options:nil];
cell = [items objectAtIndex:0];
assert(cell && [cell.reuseIdentifier isEqualToString:identifier]);
NSLog(@"That was a load - rather than a nice cache for %@", self.class);
}
fill out some stuff.
return cell;
}
なぜこれがある - それは物事がたくさんより効率的になりますよう?ありがとうございます。
Dw。
だから、複数回のNSLogを見ていますか?あなたの質問を明確にしようとしています。 –
確かに - セル識別子( 'assert'チェックと同じもの)で設定されています。 –