I'm trying to create a table view with some custom cells, but I have a problem. Everything is setup correctly and when I use this UITableVC as the initial VC it all works. But when I try to add it as a child VC to another VC, I get this error:
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'
I'm not changing anything else, I'm just moving the arrow in the storyboard to another VC to make it initial.
Here is how I'm adding the UITableVC subclass as a child to another VC:
self.statementTableViewController = [[SBStatementTableViewController alloc] init];
[self.view addSubview:self.statementTableViewController.view];
[self.statementTableViewController.view setFrame:self.contentFrame];
And here is how I dequeue a cell:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Statement Cell";
SBStatementCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
return cell;
}
I understand the above code is iOS6 only, I will worry about iOS 5 later :)
I'm guessing that the cell identifiers are somehow not "global" and the tableVC can't see them when it's a child to another VC?
Please help and let me know if you need to see some more code!