Revision: 23381
Updated Code
at March 12, 2011 03:25 by BenClayton
Updated Code
- (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.. NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"PersonDetailsInfoCell" owner:self options:nil]; id firstObject = [topLevelObjects objectAtIndex:0]; if ( [ firstObject isKindOfClass:[UITableViewCell class]] ) cell = firstObject; else cell = [topLevelObjects objectAtIndex:1]; } // set up properties... return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 68.0; // return the HEIGHT of your cell as you designed it in IB. }
Revision: 23380
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 5, 2010 09:09 by BenClayton
Initial Code
- (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.. NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"PersonDetailsInfoCell" owner:self options:nil]; id firstObject = [topLevelObjects objectAtIndex:0]; if ( [ firstObject isKindOfClass:[UITableViewCell class]] ) cell = firstObject; else cell = [topLevelObjects objectAtIndex:1]; } // set up properties... return cell; }
Initial URL
Initial Description
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).
Initial Title
load a reusable UITableViewCell from a XIB version 2
Initial Tags
Initial Language
Objective C