一个xib中放多个cell,在创建其中一个cell时,其他cell会执行awakeFromNib和dealloc方法
帅气的cc 2017-03-20 04:59:45 就是tableView中有多重cell样式,我把它们都放在了一个xib文件中了。创建cell代码如下:
NSString *idf = [NSString stringWithFormat:@"cell%ld",indexPath.row];
SleepRecordDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:idf];
if (!cell) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"SleepRecordDetailCell" owner:nil options:nil] objectAtIndex:indexPath.row];
}
return cell;
当创建cell的时候,xib中的其他cell会执行- (void)awakeFromNib 和 - (void)dealloc方法,应该就是传说中的初始化和销毁吧。我认为这样肯定会占用一定的资源,有什么解决办法吗?