-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
RWBlackListTableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"RWBlackListTableViewCell" forIndexPath:indexPath];
LYAuthorModel*model =self.viewModel.resultArrayM[indexPath.row];
[cell ly_setData:model];
cell.block = ^(UITableViewCell * _Nonnull cell) {
[RWTipsHoverView showtipsViewWithTitle:@"温馨提示"
content:@"是否将该用户在黑名单中移除?"
richText:@""
leftBtn:@"取消"
rightBtn:@"确定" callBack:^{//
//获取准确的indexPath
self.removeModel.doctorId =[NSString stringWithFormat:@"%ld",model.subscribeDoctorId];
[self.removeModel.addBlackUserCommand execute:nil];
NSIndexPath *currentIndexPath = [_tableView indexPathForCell:cell];
[self.viewModel.resultArrayM removeObjectAtIndex:currentIndexPath.row];
//beginUpdates和endUpdates中执行insert,delete,select,reload row时,动画效果更加同步和顺滑,否则动画卡顿且table的属性(如row count)可能会失效
[self.tableView beginUpdates];
//这里不能直接使用cellForRowAtIndexPath代理方法中传入的indexPath,因为在删除一次后如果继续向下删除,indexPath会因为没有刷新而产生错误
[self.tableView deleteRowsAtIndexPaths:@[currentIndexPath] withRowAnimation:UITableViewRowAnimationFade];
[self.tableView endUpdates];
[LYNotificationCenter postNotificationName:@"refreshPrivacyList" object:nil];
if (self.viewModel.resultArrayM.count==0) {
[self addEmptyView];
}
}];
};
return cell;
}
网友评论