iOS UITableView(四) 为tableView设置头尾视图,改变cell的宽度,cell的缩进

这里简单介绍一下上篇使用但没有着重突出的一些方法大家可以自己下去实现并观测效果

//设置标题头的宽度

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

{

    return 40;

}

//设置标题尾的宽度

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section

{

    return 44;

 }

//设置标题头的名称

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

{

return  [NSString stringWithFormat:@"这是第%ld组的头",section];

}

//设置标题脚的名称

-(NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section

{

return  [NSString stringWithFormat:@"这是第%ld组的脚",section];

}

//设置cell 的宽度

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

    return 44;

}

//下面两个方法可以设置头视图尾视图,我们可以在view上做任何事情,具体就看大家想怎么办了

-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{

}

-(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{

}

//允许编辑

-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{

    return YES;

}

//允许移动

-(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath

{

    return YES;

}

//一定要实现这个移动回调

-(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath{

}

//设置缩(进风格为默认)

-(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath

{

    NSUInteger row = [indexPath row];

    return row;

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值