swipe to delete when already in edit mode

后端 未结 2 1582
滥情空心
滥情空心 2021-02-08 10:19

I have an iphone app using a uitableview where I\'d like the \"reorder\" controls to always be displayed, and have the user swipe to delete rows.

The approach I\'m curre

2条回答
  •  旧巷少年郎
    2021-02-08 10:55

    When the user swipes on a given row, you need to store a reference somewhere so that you can change the value returned by editingStyleForRowAtIndexPath and shouldIndentWhileEditingRowAtIndexPath. Your best bet is likely to use indexPathForCell on the cell that is swiped and store that. Then in the two display methods above you need to check if the NSIndexPath is the same or not (I'm not sure if they will be the same pointer or if you'll need to compare the section/row values - testing required). If they match, display the delete button.

    Note that you may need to call reloadData on your tableView to have the effect appear without scrolling away and back again.

提交回复
热议问题