swift 拦截系统左滑跟返回事件

在做键盘弹出跟隐藏时候的bug

1.在嵌套Scrollerview的情况下 touchBeagen事件不能触发

  • 解决方法 自定义一个UIScrollerview 进行对touch事件的从写
class DictContentScrollView: UIScrollView {

    open override func touchesBegan(_ touches: Set, with event: UIEvent?) {
        self.next?.touchesBegan(touches, with: event)
        super.touchesBegan(touches, with: event)
    }
    
    open override func touchesMoved(_ touches: Set, with event: UIEvent?) {
        self.next?.touchesMoved(touches, with: event)
        super.touchesMoved(touches, with: event)
    }
    
    open override func touchesEnded(_ touches: Set, with event: UIEvent?) {
        self.next?.touchesEnded(touches, with: event)
        super.touchesEnded(touches, with: event)
    }

}

2.在键盘弹出之后 在返回控制器时候不能响应进行隐藏键盘的bug

  • 解决方法是拦截控制器的左滑跟返回事件
    override func willMove(toParent parent: UIViewController?) {
        noteKeyBoardView.submit()
    }

你可能感兴趣的:(swift 拦截系统左滑跟返回事件)