的allowsMultipleSelectionDuringEd

的allowsMultipleSelectionDuringEd

本文介绍了当tableView的allowsMultipleSelectionDuringEditing属性为YES时,如何进行滑动到删除工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 5中,如果我在UITableView上将 allowsMultipleSelectionDuringEditing 设置为YES,则滑动到删除不再有效。内置的Mail应用程序支持在编辑模式下滑动到删除和多个选择,我也想这样做。我如何实现这一目标?

In iOS 5, if I set allowsMultipleSelectionDuringEditing to YES on a UITableView then swipe-to-delete no longer works. The built-in Mail app supports both swipe-to-delete and multiple selections in edit mode, and I'd like to do likewise. How do I achieve this?

推荐答案

诀窍是设置 allowsMultipleSelectionDuringEditing 进入编辑模式时为YES,退出编辑模式时将其设置为NO。这样,在编辑模式下滑动到删除和多个选择都可以正常工作。

The trick is to set allowsMultipleSelectionDuringEditing to YES on entering edit mode and set it back to NO on exiting edit mode. This way, both swipe-to-delete and multiple selections in edit mode work.

如果你已经子类 UITableViewController (你可能有),然后你可以这样做:

If you've subclassed UITableViewController (which you probably have), then you can simply do this:

- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
    // Set allowsMultipleSelectionDuringEditing to YES only while
    // editing. This gives us the golden combination of swipe-to-delete
    // while out of edit mode and multiple selections while in it.
    self.tableView.allowsMultipleSelectionDuringEditing = editing;

    [super setEditing:editing animated:animated];
}

这篇关于当tableView的allowsMultipleSelectionDuringEditing属性为YES时,如何进行滑动到删除工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 21:58