Search code examples
iosobjective-cuitableviewiboutlet

IBOutlet of UITableViewCell subview is (NULL)


I have a custom UITableViewCell defined in a xib. It has two views in its Content View, a label and a text view.

In my table view controller, using either

JJDTextInputCell *cell = [[SDLTextInputCell alloc] init];

or

JJDTextInputCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TextInputCell" forIndexPath:indexPath];

the IBOutlet is null, so the table view does not show the default text or any text I try to display using

cell.descriptionLabel.text = @"foo";

What is the proper way to initialize custom UITableView cells created using interface builder?


Solution

  • Initialize them from xib file.

    JJDTextInputCell *cell = [[[NSBundle mainBundle] loadNibNamed:@"JJDTextInputCell" owner:self options:nil] objectAtIndex:0];