I'm migrating from customizing my TableViewCells in tableView:cellForRow:atIndexPath: to using a custom UITableViewCell subclass. Here's how I done it:

First, created empty XIB, dragged UITableViewCell there and put a UILabel on top. Created a class (subclass of UITableViewCell) and in Interface Builder's properties editor set the class to MyCell. Then, in my TableViewController, put the following:

- (void)viewDidLoad
{
 [super viewDidLoad];
 // load custom cell
 UINib *cellNIB = [UINib nibWithNibName:@"MyCell" bundle:nil];
 if (cellNIB)
 {
   [self.tableView registerNib:cellNIB forCellReuseIdentifier:@"MyCell"];
 } else NSLog(@"failed to load nib");
}

After that I wiped out all the custom code from tableView:cellForRow:atIndexPath: and left only default lines:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"MyCell";
    MyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    return cell;
}

When I ran this, I expected to see a bunch of cells with a single label in each cell (the very label that I dropped in the middle while creating XIB). But instead I see just plain white empty cells and adding/removing the components to the XIB layout doesn't help.

I spend A DAY trying different options like setting the reuseIdentifier in Interface Builder for custom cell XIB and loading the view in tableView:cellForRow:atIndexPath:, but none helped.

Edit
Report