ios 8 custom keyboard hold button to delete?

前端 未结 4 558
无人共我
无人共我 2021-01-13 12:03

I am currently building a custom keyboard and I am almost done. One problem that I have is with the delete button. When the user taps the delete button, it does what it shou

4条回答
  •  萌比男神i
    2021-01-13 12:36

    Swift 3 Use "allowableMovement" property

    override func viewDidLoad() {
        super.viewDidLoad()
    
        let longPress = UILongPressGestureRecognizer(target: self, action: #selector(KeyboardViewController.handleLongPress(_:)))
        longPress.minimumPressDuration = 0.5
        longPress.numberOfTouchesRequired = 1
        longPress.allowableMovement = 0.1
        buttonDelete.addGestureRecognizer(longPress)
    }
    
    func handleLongPress(_ gestureRecognizer: UIGestureRecognizer) {
        textDocumentProxy.deleteBackward()
    }
    

提交回复
热议问题