问题
I trying to make keyboard extension on SwiftUI
. My keyboard uses gestures a lot. But gestures up from keys located near the screen bottom are to be recognized as a system gesture. As it was said here I tried to use preferredScreenEdgesDeferringSystemGestures
parameter of UIInputViewController
but it does not help.
here is my code:
class MyController<Content: View>: UIHostingController<Content>{
open override var preferredScreenEdgesDeferringSystemGestures: UIRectEdge{
return [.bottom]
}
}
class KeyboardViewController: UIInputViewController {
@IBOutlet var nextKeyboardButton: UIButton!
let device = Device()
override var preferredScreenEdgesDeferringSystemGestures: UIRectEdge{
return [.bottom]
}
override func updateViewConstraints() {
super.updateViewConstraints()
}
override func viewDidLoad() {
super.viewDidLoad()
let setting = KeyboardSettings.Default
let swiftUIView = SwiftUIContainer(inputObjectDelegate: self, setting: setting)
let child = MyController(rootView: swiftUIView.environmentObject(device))
child.setNeedsUpdateOfScreenEdgesDeferringSystemGestures()
child.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(child.view)
addChild(child)
let heightConstraint = NSLayoutConstraint(item: view, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: CGFloat(setting.height))
view.addConstraint(heightConstraint)
setNeedsUpdateOfScreenEdgesDeferringSystemGestures()
}
}
I tried both, override UIHostingController
as a subclass, and override UIInputViewController
. nothin helps. Is it possible for keyboard to disable system bottom screen edge gesture?
来源:https://stackoverflow.com/questions/61227987/preferredscreenedgesdeferringsystemgestures-in-keyboard-extension-doesnt-work