Determining the current state of a cell

前端 未结 4 1470
孤独总比滥情好
孤独总比滥情好 2021-02-01 10:01

I know that a subclass of UITableViewCell can implement willTransitionToState and execute custom code at the time of transition. But is there any way t

4条回答
  •  再見小時候
    2021-02-01 10:21

    The current states are UITableViewCellStateDefaultMask (0), UITableViewCellStateShowingEditControlMask (1), UITableViewCellStateShowingDeleteConfirmationMask (2), and UITableViewCellStateShowingEditControlMask | UITableViewCellStateShowingDeleteConfirmationMask (3).

    These states correspond to the values of the properties editing and showingDeleteConfirmation. It can be tested as follows:

    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
    }
    

提交回复
热议问题