在不处于编辑模式时重新排序UITableView上的控件? [英] Reordering controls on UITableView while not in editing mode?

查看:173
本文介绍了在不处于编辑模式时重新排序UITableView上的控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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.

拥有自己的布尔值,即删除。将tableview单元格设置为 cell.showsReorderControl = YES
然后实现移动单元格所需的所有方法。我认为你正在寻找的代码是。
- tableView:editingStyleForRowAtIndexPath:
如果删除==是返回 UITableViewCellEditingStyleDelete 否则返回 UITableViewCellEditingStyleNone
最后,始终设置 tableView.editing = YES 。如果在更改删除 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上的控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆