1

最近、新しいクラス テンプレートを作成するときに、UITableViewController 実装のサブクラスである (Xcode -> ファイル -> 新規 -> ファイル) メソッドが部分的であることに気付きましたcellForRowAtIndexPath。以下にその方法を貼り付けました。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   static NSString *CellIdentifier = @"Cell";
   UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

   // Configure the cell...

   return cell;
}

(欠落している)、

if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

実装する必要があります。これはバグですか、それとも何か他のものですか?

4

1 に答える 1

1

registerNib:forCellReuseIdentifier:メソッドを使用してテーブル ビューにセルを登録する場合、またはregisterClass:forCellReuseIdentifier:xib またはストーリーボードでテーブル ビュー内にセルを作成する場合は、セルを作成する必要はありません。

于 2013-09-23T17:59:29.883 に答える