When a row in my UITableView
is swiped, the delete button is displayed. If I then add an item to this table, the row is inserted but the delete button wants to stay at the same index - so it moves to the row that it now in the same slot.
刷过我的UITableView中的一行时,会显示删除按钮。如果我然后向该表添加一个项目,则插入该行但删除按钮希望保持相同的索引 - 因此它将移动到它现在位于同一个插槽中的行。
What I would like to happen is for the row to remove the delete button when I display my modal for adding a new item. In other words, I want to set editing to NO
. However, it is not so simple - I don't want to exit edit mode when the user has entered it via the edit button. I would like to return the user to the same state that he left the table.
我想要发生的是当我显示我的模态以添加新项目时删除删除按钮的行。换句话说,我想将编辑设置为NO。但是,它并不那么简单 - 当用户通过编辑按钮输入编辑模式时,我不想退出编辑模式。我想将用户返回到他离开桌子的状态。
So - how do I tell a UITableView
to remove the delete button, but not exit edit mode altogether? Even if the user has tapped 'edit', and then used the '-' icon to present a delete button, I would like to tell the table to remove the button but remain in edit mode if necessary.
那么 - 如何告诉UITableView删除删除按钮,但不能完全退出编辑模式?即使用户点击了“编辑”,然后使用“ - ”图标显示删除按钮,我想告诉表格删除按钮,但如有必要,仍保持编辑模式。
1 个解决方案
#1
1
Remember that each UITableViewCell
instance has its own editing
property (which you can further influence with some other properties, like editingAccessoryType
). When you add a new row, you can leave the table view's editing
property alone, but manually update the editing
properties for both the old row that the user was editing and the new row that you just inserted.
请记住,每个UITableViewCell实例都有自己的编辑属性(您可以进一步影响其他一些属性,如editingAccessoryType)。添加新行时,可以单独保留表视图的编辑属性,但手动更新用户正在编辑的旧行和刚刚插入的新行的编辑属性。
#1
1
Remember that each UITableViewCell
instance has its own editing
property (which you can further influence with some other properties, like editingAccessoryType
). When you add a new row, you can leave the table view's editing
property alone, but manually update the editing
properties for both the old row that the user was editing and the new row that you just inserted.
请记住,每个UITableViewCell实例都有自己的编辑属性(您可以进一步影响其他一些属性,如editingAccessoryType)。添加新行时,可以单独保留表视图的编辑属性,但手动更新用户正在编辑的旧行和刚刚插入的新行的编辑属性。