iOS アプリケーションで動的テーブルを作成しようとしていますが、悪名高いメッセージが引き続き表示されます。
識別子 CEMBurialCell を持つセルをデキューできません - 識別子の nib またはクラスを登録する必要があります".
以下は、動作していない私のコードです。
以下は、メインコントローラーの一部のデータです。
#import "CEMBurialCell.h" // The custom cell I want to use in the tableView
@interface CEMMainViewController () <UITextFieldDelegate, UITableViewDataSource, UITableViewDelegate>
{
UITableView *deathstoday;
}
これはviewWillAppear:
メソッド内のコードです。
deathstoday = [[UITableView alloc] initWithFrame:CGRectMake(1, 370, 300, 50)];
deathstoday.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
deathstoday.delegate = self;
deathstoday.dataSource = self;
deathstoday.scrollEnabled = YES;
[self.view addSubview:deathstoday];
[self fetchfeed]; // This populates the array for the tableview
これはviewDidLoad
メソッド内のコードです。
UINib *nib = [UINib nibWithNibName:@"CEMBurialCell" bundle:nil];
[deathstoday registerNib:nib forCellReuseIdentifier:@"CEMBurialCell"];
ここでエラーが発生します:
識別子 CEMBurialCell を持つセルをデキューできません - 識別子の nib またはクラスを登録するか、ストーリーボードのプロトタイプ セルを接続する必要があります。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CEMBurialCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"CEMBurialCell" forIndexPath:indexPath];
メソッドでを初期化したCEMBurialCell
のにviewDidLoad
、なぜこのエラーが発生するのですか? このルーチンは、次の init を持つプログラムで動作するようになりました。
self = [super initWithStyle:UITableViewStylePlain]; // in program that does work
一方、動作しないプログラムには初期化があります
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; // in program that doesn't work
したがって、上記の 2 つの行は、2 つのプログラムの主な違いです。UITableView
セルに actionBlock が必要なため、セルではなくカスタム セルを使用しました。では、2 番目のプログラムでカスタム セルでエラーが発生するのはなぜですか? CEMBurialCell
他のプログラムでも同じカスタム セルが機能します。私は何が欠けていますか?