#pragma mark -- tableViewcellDele
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
//第1/5组可以左滑删除
if (indexPath.section == 0 ) {
if(indexPath.row == self.worksArray.count){
return NO;
}
return YES;
}
else if (indexPath.section == 5){
if(indexPath.row == self.RightsListArray.count){
return NO;
}
return YES;
}
return NO;
}
// 定义编辑样式
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleDelete;
}
// 进入编辑模式,按下出现的编辑按钮后,进行删除操作
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {//删除状态
if(indexPath.section == 0){
[self.worksArray removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];
}else if (indexPath.section == 5){
[self.RightsListArray removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];
}
}
}
// 修改编辑按钮文字
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"删除";
}
tableViewCell滑动删除,局部刷新
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 情景:侧滑抽屉效果中,TableView的cell左滑删除手势与一个全屏的侧滑手势(响应侧滑效果的手势)冲突
- UITableView对于iOS开发者来说一定不会陌生,很有可能你的APP很多界面都用到它。关于UITableVi...