UIGestureRecognizer and UITableViewCell issue

前端 未结 4 1596
囚心锁ツ
囚心锁ツ 2020-11-27 11:14

I am attaching a UISwipeGestureRecognizer to a UITableViewCell in the cellForRowAtIndexPath: method like so:

- (UITabl         


        
4条回答
  •  感动是毒
    2020-11-27 12:15

    Adding gesture in AwakeFromNib method works with no problems.

    class TestCell: UITableViewCell {
    
        override func awakeFromNib() {
            super.awakeFromNib()
    
            let panGesture = UIPanGestureRecognizer(target: self,
                                                action: #selector(gestureAction))
            addGestureRecognizer(panGesture)
        }
    
        @objc func gestureAction() {
            print("gesture action")
        }
    }
    

提交回复
热议问题