仅在指定部分启用 UITableView 编辑 [英] Enable UITableView edit only in a specified section
问题描述
我有一个包含 4 个部分的 tableView.我想仅在第四部分中启用编辑(移动/拖动/重新排列)单元格.当我设置: tableView.editing = YES
我让所有表格视图都处于编辑模式.这个如何将 UITableView 行重新排序限制为一个部分帮助了我,因为我现在只能在根"部分中重新排列一个部分中的单元格.
I have a tableView with 4 sections. I want to enable editing (move/drag/ rearrange ) the cells only within the forth section. When I set: tableView.editing = YES
I get all the table view to be in editing mode. This How to limit UITableView row reordering to a section helped me as I can now rearrange cells from a section only within their "root" section.
我的意思是,如果单元格在第 1 部分,那么我只能在第 1 部分而不是其他部分重新排列.我的目标是仅使用第四部分启用编辑,因此仅将第四部分中的单元格置于移动/拖动模式.有谁知道我该怎么做?
What I mean is if the cell is in the 1st section then I only get to rearrange within the 1st section and not the others. My goal is to enable editing only with The 4th section therefore putting in Move/drag Mode only the cells within the 4th Section. Does anyone know how I can do this?
推荐答案
你可以通过实现这个委托方法来实现
You can achieve this by implementing this delegate method
-(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 3) {
return YES;
} else {
return NO;
}
}
这篇关于仅在指定部分启用 UITableView 编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!