UITaleView 多选

效果就是 cell.contentView 右移,左侧留一空圆,点击选中,再点取消选中。

[_rootTable setEditing:YES animated:YES];进入多选,然后实现 delegate:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {  // 关键所在  return UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert; }  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {  if (tableView.editing) {  if (_dataArray && [_dataArray count]>indexPath.row) {  NSDictionary *dict = [_dataArray objectAtIndex:indexPath.row];  [_pickedArray addObject:dict];  }  } }  - (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {  if (tableView.editing) {  if (_dataArray && [_dataArray count]>indexPath.row) {  NSDictionary *dict = [_dataArray objectAtIndex:indexPath.row];  [_pickedArray removeObject:dict];  }  } } 

你可能感兴趣的:(view)