Skip to content

Instantly share code, notes, and snippets.

@jlcampana
Created August 23, 2012 06:30
Show Gist options
  • Save jlcampana/3433394 to your computer and use it in GitHub Desktop.
Save jlcampana/3433394 to your computer and use it in GitHub Desktop.
cellForRowAtIndexPath (iOS5 ver)
- (UITableViewCell*) tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
static NSString* customCellIdentifier = @"CustomCellIdentifier";
CustomCell* cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:customCellIdentifier];
if (cell == nil)// tableview not associated (registered) with nib file.
{
UINib* customCellNib = [UINib nibWithNibName:@"CustomCell" bundle:nil]; // Register this nib file with cell identifier.
[tableView registerNib: customCellNib forCellReuseIdentifier:customCellIdentifier];
}
cell = (CustomCell*) [tableView dequeueReusableCellWithIdentifier:customCellIdentifier]; // call dequeueReusableCellWithIdentifier function and now you will get cell object
return (UITableViewCell*)cell;
}
/*
Note:-
#1 Cell nib file must contain a single table view cell.
#2 Cell reuse identifier must be same as that in xib.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment