ios uitableviewcell 的具体功能实现
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier;
Cell的初始化方法,可以设置一个风格和标识符,风格的枚举如下:
UITableViewCellStyle) {
UITableViewCellStyleDefault, // 默认风格,自带标题和一个图片视图,图片在左
UITableViewCellStyleValue1, // 只有标题和副标题 副标题在右边
UITableViewCellStyleValue2, // 只有标题和副标题,副标题在左边标题的下边
UITableViewCellStyleSubtitle // 自带图片视图和主副标题,主副标题都在左边,副标题在下
};
//设置单元格高度
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 90;
}
//设置单元格缩进
-(NSInteger) tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger row = [indexPath row];
if (row % 2==0) {
return 0;
}
return 2;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
这个方法返回指定的 section的header view 的高度。
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;
这个方法返回指定的 section的footer view 的高度。