iOS开发中,有时候需要实现tableView中cell的单选或者复选,这里举例说明了怎么简单的实现
首先自己创建一个列表,实现单选,先定义一个变量记录每次点击的cell的indexPath:
@property (assign, nonatomic) NSIndexPath *selIndex;//单选,当前选中的行
然后在下面的代理方法实现代码
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//之前选中的,取消选择
UITableViewCell *celled = [tableView cellForRowAtIndexPath:_selIndex];
celled.accessoryT

本文介绍了在iOS开发中如何简单实现UITableView的单选和复选功能。通过定义变量记录选中行的indexPath来实现单选,利用数组存储选中行的坐标以实现复选。同时,针对cell的复用问题,文章提供了相应的处理方法。附带了一个demo的下载链接。
最低0.47元/天 解锁文章
11

被折叠的 条评论
为什么被折叠?



