Hi,
I'm trying to create a single custom UITableViewCell from a xib, among other normal UITableViewCell's. I've tried quite a few varied things with no success. Can anyone help me please?
Hi,
I'm trying to create a single custom UITableViewCell from a xib, among other normal UITableViewCell's. I've tried quite a few varied things with no success. Can anyone help me please?
The simplest method is to create an outlet for the tablecell in your tableViewController and then wire that outlet to the custom cell in Interface Builder. Place the cell in the nib of which the tableViewController is the File Owner.
So the definition would look like
IBOutlet UITableViewCell *myCustomCell;
...
@property(nonatomic, retain) IBOutlet UITableViewCell *myCustomCell;
and to use it, you would:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
....
(some condition test)
cell=self.myCustomCell;
(configure cell)
return cell;
}
I've squeezed dozens of custom cells into a nib with no problem. The technique is especially useful when your creating a preference style table in which every cell is unique.