我的自定义键盘上在屏幕的左侧和右侧都有按钮,它们具有.touchdown操作。当我单击它们时,他们没有立即注册.touchdown,似乎正在等待查看是否有滑动手势。我尝试使用代码来推迟边缘手势,但是在iOS 13中,这似乎并没有解决问题。有没有人提供一种解决方案,使单击时如何使边缘的按钮立即执行.touchdown操作?
override var preferredScreenEdgesDeferringSystemGestures: UIRectEdge {
return [.left, .bottom, .right]
}
我还尝试在自定义按钮类中使用point函数,但这只会使其突出显示,但仍然无法立即执行操作。
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
let inside = super.point(inside: point, with: event)
if inside && !isHighlighted && event?.type == .touches {
isHighlighted = inside
}
return bounds.insetBy(dx: -2.7, dy: -12).contains(point)
}
答案 0 :(得分:0)
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if let window = view.window,
let recognizers = window.gestureRecognizers {
recognizers.forEach { r in
r.delaysTouchesBegan = false
r.cancelsTouchesInView = false
r.isEnabled = false
}
}
}