我有一个 UITableView,我希望能够在我不处于编辑模式时重新排序行,这意味着我不想看到删除图标,直到我按下编辑.我希望能够一直看到和使用重新排序控件.这可能吗?
I have a UITableView and I want to be able to reorder the rows when I'm not in edit mode, meaning I don't want to see the delete icons until I press Edit. I want to be able to see and use the reordering controls all the time. Is that possible?
我是否必须始终将 UITableView 保持在编辑模式并手动启用/禁用删除图标?在这种情况下如何禁用滑动删除?
Do I have to keep the UITableView in editing mode all the time and enable/disable the delete icon manually? How to disable the swipe to delete in that case?
据我所知,仅使用编辑标志是无法做到的.但是,要达到类似的效果并不难.
As far as I'm aware you can't do it using just the editing flag. However, it's not hard to achieve a similar effect.
有你自己的布尔值,即deleting
.将 tableview 单元格设置为 cell.showsReorderControl = YES
.然后实现移动单元格所需的所有方法.我认为您正在寻找的代码是.--tableView:editingStyleForRowAtIndexPath:
如果 deleting == YES
返回 UITableViewCellEditingStyleDelete
否则返回 UITableViewCellEditingStyleNone
.最后,始终设置 tableView.editing = YES
.如果在更改 deleting
bool 之前和之后运行 [tableView beginUpdates]
和 [tableView endUpdates]
一切都应该正常.如果这没有意义,请告诉我,我会再试一次.
Have your own boolean ie deleting
. Set the tableview cell to cell.showsReorderControl = YES
.
Then implement all the methods required for moving cells. The bit of code I think you're looking for is.
– tableView:editingStyleForRowAtIndexPath:
if deleting == YES
return UITableViewCellEditingStyleDelete
otherwise return UITableViewCellEditingStyleNone
.
Finally, set tableView.editing = YES
always. If before and after changing the deleting
bool you run [tableView beginUpdates]
and [tableView endUpdates]
everything should work fine. Let me know if this doesn't make sense, and I'll try again.
这篇关于不在编辑模式下重新排序 UITableView 上的控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!