Determining the current state of a cell

前端 未结 4 1472
孤独总比滥情好
孤独总比滥情好 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:28

    The swift version of jhilgert00 with Neil's comment applied:

    override func willTransitionToState(state: UITableViewCellStateMask) {
    
        super.willTransitionToState(state)
    
        if (state == UITableViewCellStateMask.DefaultMask) {
            println("default")
        } else if (state & UITableViewCellStateMask.ShowingEditControlMask != nil)
            && (state & UITableViewCellStateMask.ShowingDeleteConfirmationMask != nil) {
                println("Edit Control + Delete Button")
        } else if state & UITableViewCellStateMask.ShowingEditControlMask != nil {
            println("Edit Control Only")
        } else if state & UITableViewCellStateMask.ShowingDeleteConfirmationMask != nil {
            println("Swipe to Delete [Delete] button only")
        }
    }
    

提交回复
热议问题