preferredScreenEdgesDeferringSystemGestures in keyboard extension doesnt work

孤者浪人 提交于 2020-04-18 05:46:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!