/ Published in: Objective C
Create a UITableViewCell subclass, add outlets for the controls you'll add later. Create a View-based NIB Delete the default 'view' in IB Add a 'Table View Cell' instance Set the 'Class Identity' to your UITableViewCell subclass. Set the 'Identifier' (this is the reuse identifier) to be the name of your class - e.g. PersonDetailsInfoCell. Add the controls you want in IB Link the controls to the outlets in your subclass.
Then to actually load the custom cells add this odd piece of boilerplate code.. (here PersonDetailsInfoCell is my UITableViewCell subclass).
Expand |
Embed | Plain Text
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { PersonDetailsInfoCell *cell = (PersonDetailsInfoCell *)[tableView dequeueReusableCellWithIdentifier:@"PersonDetailsInfoCell"]; if ( cell == nil ) // i.e. there isn't a reusable one I can use. { // wierd boilerplate code for loading the cell from a NIB.. id firstObject = [topLevelObjects objectAtIndex:0]; if ( [ firstObject isKindOfClass:[UITableViewCell class]] ) cell = firstObject; else cell = [topLevelObjects objectAtIndex:1]; } // set up properties... return cell; } return 68.0; // return the HEIGHT of your cell as you designed it in IB. }
You need to login to post a comment.
