次のエラーが表示されます。
*キャッチされない例外 'NSInternalInconsistencyException' が原因でアプリを終了します。理由: '識別子 FontCell を持つセルをデキューできません - 識別子のペン先またはクラスを登録するか、ストーリーボードでプロトタイプ セルを接続する必要があります'
何が間違っているのか正確にはわかりません。セル識別子を設定し (Interface Builder を介して作成されていないため、プログラムで)、デリゲート メソッドで実行する必要があると思っていたすべてのことを行いますが、UITableView をロードしようとすると、まだエラーが発生します。
関連するコードは次のとおりです (カスタマイズ オプションのために UITableViewCell をサブクラス化したことに注意してください)。
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.fonts.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"FontCell";
FontCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
if (!cell) {
cell = [[FontCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"FontCell"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
int row = indexPath.row;
cell.fontFamilyLabel.text = self.fonts[row];
return cell;
}
そして、サブクラス化された UITableViewCell (FontCell) で変更した唯一のメソッドは次のとおりです。
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.fontFamilyLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 200, 20)];
self.fontFamilyLabel.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:self.fontFamilyLabel];
}
return self;
}
私は正確に何を間違っていますか?