カスタム UITableViewCell アプリを読み込もうとするとクラッシュします。これまで何度もやっていましたが、今回も同じようにしました。クラッシュの原因がコメントされているコードの一部 (// この部分はクラッシュを引き起こしています):
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CustomTableCell";
CustomTableCell *cell = (CustomTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
// This part is causing crash
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomTableCell" owner:nil options:nil];
cell = [topLevelObjects objectAtIndex:0];
}
return cell;
}
CustomTableCell.h、CustomTableCell.m、CustomTableCell.xib があります。
CellIdentifier は CustomTableCell であり、ペン先名にスペースの問題はありません。
エラーのスクリーンショット:
クラッシュの原因は何ですか?