![](/img/trans.png)
[英]Allow UITableView to reorder, but not delete in edit mode, and enable swipe to delete anyway
[英]Enable Reorder Control in UITableView as default without being in edit mode
我目前正在研究一种解决方案,在该解决方案中,默认情况下我需要在重新排序模式下使用UITableView
,而没有删除按钮,但可以在必要时启用删除按钮。 我只是好奇这是否可以在 iOS 中实现? 如果是这样,我的方法应该是什么?
在我看来,您的表格视图应该始终处于编辑模式。
要使重新排序控件出现,您应该实现 UITableViewDataSource 方法
tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool
和
tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath)
如果您不希望显示删除按钮,您可以通过实现
tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle
和 return.none 默认情况下或.delete 当您想要显示按钮时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.