RxSwiftCommunity / RxKeyboard

Reactive Keyboard in iOS
MIT License
1.6k stars 175 forks source link

interactive dismiss event is not continuous update keyboard height. #105

Open thecsy opened 3 years ago

thecsy commented 3 years ago

interactive dismiss event is not continuous update keyboard height. just one height Update, in start & end point.

i used storyboard & autolayout. i need continuous visible Keyboard height. how to use ?

스크린샷 2021-01-21 오후 12 26 45

Simulator Screen Shot - iPhone 8 Plus - 2021-01-21 at 12 24 49

kyrie-siu commented 3 years ago

I met the same issue and I finally fixed it.

In my case, I had add a new UIWindow in my app then the panGestureRecognizer from RxKeyboard didn't added to the correct window.

Here is my solution by editing source code to make sure I am getting the keyWindow:

if let window = UIApplication.shared.windows.first(where: { (window) -> Bool in window.isKeyWindow}) {
    window.addGestureRecognizer(self.panRecognizer)
} else {
    UIApplication.rx.didFinishLaunching // when RxKeyboard is initialized before UIApplication.window is created
        .subscribe(onNext: { _ in
          if let window = UIApplication.shared.windows.first(where: { (window) -> Bool in window.isKeyWindow}) {
            window.addGestureRecognizer(self.panRecognizer)
          }
    }).disposed(by: disposeBag)
}

If you don't want to modify the source code, call RxKeyboard.instance after setting a new window should solve the issue as well:

window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
RxKeyboard.instance

Hope that could help!