カスタムのテーブルビューセルを作成しました。クラスには 3 つのラベルがあります。マスター ビュー コントローラー テンプレートを使用して開始し、ストーリーボードの既定の tableviewcell を新しいカスタム セルを参照するように変更し、タイプをカスタムに、識別子を 'CustomTableCell' に変更しました。cellForRowAtIndexPath メソッドも次のように変更しました...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"CustomTableCell";
CustomTableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell)
{
cell = [[CustomTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
Item *currentItem = _objects[indexPath.row];
cell.nameLabel.text = [currentItem name];
cell.vegLabel.text = @"V";
return cell;
}
カスタム セル ヘッダー ファイル
#import <UIKit/UIKit.h>
@interface CustomTableCell : UITableViewCell
@property (nonatomic, weak) IBOutlet UILabel *nameLabel;
@property (nonatomic, weak) IBOutlet UILabel *vegLabel;
@property (nonatomic, weak) IBOutlet UILabel *priceLabel;
@end
ストーリーボードでは、すべてが適切に接続されているようです。デバッグすると、セルにカスタム セルのプロパティがあることがわかります。しかし、アプリケーションを実行すると、各行が空白になります。tableviewcell は、ストーリー ボードで正しい識別子を使用しています。何が欠けているのかわかりません。どんな助けでも大歓迎です。ありがとう。