https://blog.csdn.net/feng2qing/article/details/51407156
1>純代碼自定義UITableviewCell
繼承UITableviewCell,重寫cell的initWithStyle:withReuseableCellIdentifier
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
? ? if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
? ? ? ? //布局cell內(nèi)部控件? ? ? ? [self setupUI];
? ? }
? ? return self;
}
為tableView注冊cell,使用registerClass:forCellReuseIdentifier:方法注冊
[_tableView registerClass:[FooterCell Class] forCellReuseIdentifier:CellIdentifier];
在cellForRowAtIndexPath中使用dequeueReuseableCellWithIdentifier:forIndexPath:獲取重用的cell,若無重用的cell,將自動使用所提供的class類創(chuàng)建cell并返回
FooterCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];?
獲取cell時若無可重用cell,將調(diào)用cell中的initWithStyle:withReuseableCellIdentifier:方法創(chuàng)建新的cell