UITableViewCell:允许选择性删除

编程入门 行业动态 更新时间:2024-10-13 00:31:24
本文介绍了UITableViewCell:允许选择性删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个表格视图,并希望允许对所有单元格进行重新排序,但是有些单元格我不希望被删除。当UiTableView进入删除模式时,我不希望红色的-按钮出现在左侧,也不想通过滑动手势调出这些单元格的删除按钮,但希望其他用户也可以使用。有任何想法吗?

I have a table view and want to allow reordering of all cells, however there are certain cells that I do not want to be allowed to be deleted. when the UiTableView is put into deletion mode I do not want the red '-' button to appear on the left hand side, and do not want the swipe gesture to bring up the Delete button of these cells but want it to happen for the others. Any ideas?

推荐答案

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{ //if we cant delete the object represented at the index path if ([[tableViewObjectsArray objectAtIndex:indexPath.row] canBeDeleted] == NO){ return UITableViewCellEditingStyleNone; } //otherwise allow the deletion else{ return UITableViewCellEditingStyleDelete; } }

当然,这会留一个空白, '按钮应该是,但不允许删除。并且也不允许刷卡删除。

Of course this leaves an empty space where the '-' button should be, but it does not allow deletion. And also does not allow the swipe deletion either.

更多推荐

UITableViewCell:允许选择性删除

本文发布于:2023-10-27 10:46:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1533144.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:选择性   UITableViewCell

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!