Created
August 23, 2012 06:30
-
-
Save jlcampana/3433394 to your computer and use it in GitHub Desktop.
cellForRowAtIndexPath (iOS5 ver)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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