iOS开发:UITableView编辑——cell的删除和移动

这篇博客介绍了在iOS开发中如何实现UITableView的编辑功能,包括单元格的删除和移动操作。通过设置数据源方法,实现编辑模式,启用删除和移动样式,并在用户确认删除或移动后更新数据源和界面。同时,文章还展示了自定义分区标题视图和尾视图的方法。
摘要由CSDN通过智能技术生成

iOS开发:UITableView编辑——cell的删除和移动


   首先在昨天的基础上添加一个sectionArray数组(详见《UI第九天:UITableView简单介绍》)

self.sectionArray= [NSMutableArrayarrayWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G",nil];


 1、section的常用方法:(效果见下图)

#pragma mark section的个数(分区个数)

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return_sectionArray.count;

    }

#pragma mark 显示section分区的标题

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

      return [_sectionArrayobjectAtIndex:section];

  }

#pragma mark 分区标题的高度

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

       return 100;

 }

2、添加右侧索引栏:(效果见下图)

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{

    

return _sectionArray;

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值