iOS - Delayed “Touch Down” event for UIButton in UITableViewCell

前端 未结 7 1193
傲寒
傲寒 2020-12-01 00:10

I have a custom UITableViewCell, which is initialized by the following:

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIden         


        
7条回答
  •  无人及你
    2020-12-01 00:30

    Swift 3 version of Alex's answer:

    override func touchesBegan(_ touches: Set, with event: UIEvent?) {
        isHighlighted = true
        super.touchesBegan(touches, with: event)
    }
    
    override func touchesEnded(_ touches: Set, with event: UIEvent?) {
        isHighlighted = false
        super.touchesEnded(touches, with: event)
    }
    
    override func touchesCancelled(_ touches: Set, with event: UIEvent?) {
        isHighlighted = false
        super.touchesCancelled(touches, with: event)
    }
    

提交回复
热议问题