UITableView 的操作

来源:互联网 发布:交换机镜像端口抓包 编辑:程序博客网 时间:2024/05/20 22:02

UITableView的row 和Section删除

当section下面有多行row时

      // 1. 更新数据        KHModel_CartHeader *mo_header = dataSource[indexpath.section];        [mo_header.model.goodsArray removeObjectAtIndex:indexpath.row];    // 2.更新UI        [tableview deleteRowsAtIndexPaths:@[indexpath] withRowAnimation:UITableViewRowAnimationAutomatic];

当section下面仅有且只有一行row时

  [dataSource removeObjectAtIndex:indexpath.section];  [tableview deleteSections:[NSIndexSet indexSetWithIndex:indexpath.section] withRowAnimation:UITableViewRowAnimationAutomatic];     

TableView的展示

这里写图片描述
现在我需要去掉那块灰色,OK直接上代码:

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{    KHUITVHeader_Cart *view = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"header"];    KHModel_CartHeader *mo = [dataSource objectAtIndex:section];    view.object = mo;    typeof (self)weakSelf = self;    view.block_itemSelected = ^(id obj) {        [weakSelf setForHeaderGoodsSelected:((UIButton *)obj).selected model:mo];    };    return view;}- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{    return 50+0.01;}-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{    return 0.01;}

题外话:这篇文章那个gif使用Giphy Capture这个软件录的,下载地址:https://itunes.apple.com/cn/app/giphy-capture.-the-gif-maker/id668208984?mt=12

0 0
原创粉丝点击