How do I set up an UIScreenEdgePanGestureRecognizer using Interface Builder?

后端 未结 7 1423
自闭症患者
自闭症患者 2021-02-06 23:48

I can\'t get UIScreenEdgePanGestureRecognizer to work when I create when I add it to my view controller using Interface Builder, so I\'m asking here to establish wh

7条回答
  •  爱一瞬间的悲伤
    2021-02-07 00:20

    Xcode isn’t always a good neighbor. Sorry.

    override func viewDidLoad() {
        super.viewDidLoad()
    
        let panGesture = UIScreenEdgePanGestureRecognizer(target: self, action: "panAction:")
        panGesture.edges = .Left
        view.addGestureRecognizer(panGesture)
    }
    
    
    func panAction(sender: UIScreenEdgePanGestureRecognizer) {
        let translation = sender.translationInView(sender.view!)
    
        println("Trans:\(translation)")
    }
    

提交回复
热议问题