tableViewCell 多选,索引,汉字排序,左滑操作

1.多选的实现,直接设置tableview的两个属性就可以了。

_tableview.allowsMultipleSelectionDuringEditing =YES;

 [_tableviewsetEditing:YESanimated:YES];//之所以这样写,没有直接用点语法是因为这样有动画效果。

系统默认选中的时候颜色是蓝色的,修改颜色的话,直接用_tableView.tintColor属性就可以了。

2.左滑操作,是ios8才支持的。直接写在代理方法里面,返回一个UITableViewRowAction的数组。(这个用第三方库也能实现,一个牛逼的左右滑动的第三方https://github.com/MortimerGoro/MGSwipeTableCell)

- (nullableNSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewRowAction *deleteRoWAction = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDestructivetitle:@"工单"handler:^(UITableViewRowAction *action,NSIndexPath *indexPath) {
        CreatNew_ViewController *creatVC = [[CreatNew_ViewControlleralloc]init];
        creatVC.detailDataArray =_dataArray;
        creatVC.cellPage = indexPath.row;
        [self.navigationControllerpushViewController:creatVCanimated:YES];
    }];//此处是iOS8.0以后苹果最新推出的api,UITableViewRowAction,Style是划出的标签颜色等状态的定义,这里也可自行定义
    UITableViewRowAction *editRowAction = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleNormaltitle:@"分配"handler:^(UITableViewRowAction *action,NSIndexPath *indexPath) {
        _isAlone =YES;
        if (!isopen) {
            buttomView.hidden =NO;
            [UIViewanimateWithDuration:0.5animations:^{
                buttomView.frame =CGRectMake(0,kMainScreenH-44-40-200,kMainScreenW,240);
            }];
        }else
        {
            [UIViewanimateWithDuration:0.5animations:^{
                buttomView.frame =CGRectMake(0,kMainScreenH-44,kMainScreenW,240);
            } completion:^(BOOL finished) {
                buttomView.hidden =YES;
            }];
        }
        isopen = !isopen;
    }];
    editRowAction.backgroundColor = [UIColorcolorWithRed:0green:124/255.0blue:223/255.0alpha:1];//可以定义RowAction的颜色
    return@[deleteRoWAction, editRowAction];//最后返回这俩个RowAction的数组
}


3.索引和汉字排序用的人家写好的类,系统自带的类也可以实现。

demo百度云:链接: http://pan.baidu.com/s/1gf0MQp9 密码: 2u34

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值