启用重新排列时,无法从单元格检索过渡状态

时间:2014-10-11 20:19:00

标签: ios xcode uitableview state

我在导航控制器中有一个UITableViewController。我使用方法

检索UITableViewCell类中的单元格状态
- (void)willTransitionToState:(UITableViewCellStateMask)state;

完全没问题,但是当我启用

重新排列表格视图时
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath;

州的值为021474836492147483650& 2147483651代替012& 3

有没有办法解决这个问题,或者我错过了什么?

1 个答案:

答案 0 :(得分:0)

支持的状态如下:

UITableViewCellStateDefaultMask (0),
UITableViewCellStateShowingEditControlMask (1),
UITableViewCellStateShowingDeleteConfirmationMask (2), and 
UITableViewCellStateShowingEditControlMask | UITableViewCellStateShowingDeleteConfirmationMask (3).

因此可以使用以下代码确认这些状态:

以下适用于任何过渡状态,也可以处理滑动以删除手势。

- (void)willTransitionToState:(UITableViewCellStateMask)state {

[super willTransitionToState:state];
if (!cell.editing && !cell.showingDeleteConfirmation) {
    // 0 - UITableViewCellStateDefaultMask
} else if (cell.editing && !cell.showingDeleteConfirmation) {
    // 1 - UITableViewCellStateShowingEditControlMask
} else if (!cell.editing && cell.showingDeleteConfirmation) {
    // 2 - UITableViewCellStateShowingDeleteConfirmationMask
} else if (cell.editing && cell.showingDeleteConfirmation) {
    // 3 - UITableViewCellStateShowingEditControlMask | UITableViewCellStateShowingDeleteConfirmationMask

}
}