Last active
December 7, 2015 15:09
-
-
Save conscientiousness/91ae1e9f568c7e5c87d0 to your computer and use it in GitHub Desktop.
dequeueReusableCellWithIdentifier
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
//=====(1)===== | |
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate> | |
{ | |
UINib * nib; | |
} | |
@end | |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ | |
if (nib == nil) { | |
nib = [UINib nibWithNibName:@"GameTableViewCell" bundle:nil]; | |
[tableView registerNib:nib forCellReuseIdentifier:@"GameTableViewCell"]; | |
} | |
GameTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"GameTableViewCell"]; | |
return cell; | |
} | |
//=====(2)===== | |
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ | |
GameTableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"GameTableViewCell"]; | |
if(cell==nil){ | |
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"GameTableViewCell" owner:self options:nil]; | |
cell = nib[0]; | |
} | |
return cell; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment