Custom UITableViewCell from xib isn't displaying properly

Posted by Kenny Wyland on Stack Overflow See other posts from Stack Overflow or by Kenny Wyland
Published on 2011-03-18T00:06:03Z Indexed on 2011/03/18 0:10 UTC
Read the original article Hit count: 194

I've created custom UITableCells a bunch of times and I've never run into this problem, so I'm hoping you can help me find the thing I've missed or messed up. When I run my app, the cells in my table view appear to be standard cells with Default style.

I have SettingsTableCell which is a subclass of UITableViewCell. I have a SettingsTableCell.xib which contains a UITableViewCell and inside that are a couple labels and a textfield. I've set the class type in the xib to be SettingsTableCell and the File's Owner of the xib to my table controller.

My SettingsTableController has an IBOutlet property named tableCell. My cellForRowAtIndexPath contains the following code to load my table view xib and assign it to my table controller's tableCell property:

static NSString *CellIdentifier = @"CellSettings";

SettingsTableCell *cell = (SettingsTableCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    [[NSBundle mainBundle] loadNibNamed:@"SettingsTableCell" owner:self options:nil];

    cell = self.tableCell;
    self.tableCell = nil;
    NSLog(@"cell=%@", cell);
}

This is what my xib set up looks like in IB: Screenshot of Interface Builder

When I run my app, the table displays as if all of the cells are standard Default style cells though: Screenshot of my table view

The seriously weird part is though... if I tap on the area of the cell where the textfield SHOULD be, the keyboard does come up! The textfield isn't visible, there's no cursor or anything like that... but it does respond. The visible UILabel is obviously not the UILabel from my xib though because the label in my xib is right justified and the one showing in the app is left justified.

I'm incredibly confused about how this is happening. Any help is appreciated.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about ios