美文网首页
tableview关于cell一些用法

tableview关于cell一些用法

作者: 刘栋 | 来源:发表于2016-06-03 08:32 被阅读105次
//新版本需要在编辑状态勾选消息的时候限制最多勾选50条

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     //判断选中消息数量,小于50加1,大于50给出提示并且不能勾选
        if (self.mutilArray.count < 50)
        {
            [self.mutilArray addObject:[self.dataArray objectAtIndex:indexPath.row]];
        }
        else
        {
            [self.view makeToast:@"最多选择50条哦"];
            UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
            cell.selected = NO;
        }    
}

//新版本在编辑状态下多选cell的时候,下拉加载历史数据的时候被选择的cell取消了
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{

    if (self.isTableViewSelect || self.infoTableView.editing == YES)//不需要看
    {
        ModelChatList *da=[self.dataArray objectAtIndex:indexPath.row];//存放历史消息model数组
        if([self.mutilArray containsObject:da])//self.mutilArray存放选择cell的消息model数组与da进行匹配
        {
//匹配历史消息中有之前被选择的消息model, 绘制选择状态
            [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
        }
        else
        {
//没有匹配则取消选择
            [tableView deselectRowAtIndexPath:indexPath animated:NO];
        }
    }
}


相关文章

网友评论

      本文标题:tableview关于cell一些用法

      本文链接:https://www.haomeiwen.com/subject/wtwkdttx.html