Have have created a child of UITableViewCell, MenuItem which contains functionality for my custom table cell. I have also created a xib-file with a custom cell and set the UITableViewCell in the xib-file to have the class MenuItem. The name of the xib-file is MenuItem as well. In my UITableViewController class I’m doing this in ViewDidLoad:
UINib *menuItems = [UINib nibWithNibName:@"MenuItem" bundle:nil];
[[self tableView] registerNib:menuItems forCellReuseIdentifier:@"MenuItem"];
But the background color used in the xib-file isn’t used in the cells the table displays. If I add a new label, it shows up, but the background color is just plain white. Does anyone know why?
EDIT: I do use [tableView dequeueReusableCellWithIdentifier:@"MenuItem"]; in cellForRowAtIndexPath.
Thanks to Sudha for links to the answer.
It turns out you can’t set the background color in the xib-file. You have to do it in the willDisplayCell of the delegate. Read http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewCell_Class/Reference/Reference.html, outlined box close to the top.