1從xib中加載cellcode
static NSString *Identifier = @"CellID"; if(!nib){ nib = [UINib nibWithNibName:@"NewsCell" bundle:nil]; [tableView registerNib:nib forCellReuseIdentifier:Identifier]; } NewsCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier]; //在cell xib 要設置Identifier
2代碼加載it
cell = [[NewsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Identifier];
3從xib加載cell(每次都從新加載nib)io
NSArray *objects = [[NSBundle mainBundle] loadNibNamed:@"NewsCell" owner:self options:nil] ; cell = [objects lastObject]; NSLog(@"%ld",objects.count); for(NSObject *o in objects){ if([o isKindOfClass:[NewsCell class]]){ cell = (NewsCell *)o; break; } }