いくつかのカスタムセルを使用してテーブルビューを作成しようとしていますが、問題があります。すべてが正しくセットアップされており、このUITableVCを初期VCとして使用すると、すべて機能します。しかし、それを子VCとして別のVCに追加しようとすると、次のエラーが発生します。
Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2372/UITableView.m:4460
2013-02-05 18:37:25.704 SalesBot[16284:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Statement Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
他には何も変更していません。ストーリーボードの矢印を別のVCに移動して、初期化しています。
UITableVCサブクラスを子として別のVCに追加する方法は次のとおりです。
self.statementTableViewController = [[SBStatementTableViewController alloc] init];
[self.view addSubview:self.statementTableViewController.view];
[self.statementTableViewController.view setFrame:self.contentFrame];
そして、これが私がセルをデキューする方法です:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Statement Cell";
SBStatementCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
return cell;
}
上記のコードはiOS6のみであることを理解しています。後で、iOS5について心配します:)
セル識別子はどういうわけか「グローバル」ではなく、別のVCの子である場合、tableVCはそれらを認識できないと思いますか?
さらにコードを確認する必要がある場合は、サポートしてお知らせください。