freshOS / KeyboardLayoutGuide

⌨️ KeyboardLayoutGuide, back from when it didn't exist.
MIT License
1.19k stars 59 forks source link

Not working properly with Tabbar #19

Open bhavneet0812 opened 5 years ago

bhavneet0812 commented 5 years ago

simulator screen shot - iphone xs max - 2019-02-26 at 12 27 48 simulator screen shot - iphone xs max - 2019-02-26 at 12 27 45

binho commented 5 years ago

Hey 👋 Not sure if you still with this issue but I was able to solve that by adding the tab bar height when decreasing the keyboard height:

@objc
private func keyboardWillChangeFrame(_ notification: Notification) {
    guard var height = notification.keyboardHeight else { return }

    // When tab bar is presented we need to include the tab bar height when adjusting the keyboard height
    let navigationController = UIApplication.shared.keyWindow?.rootViewController as? UINavigationController
    let tabBarController = navigationController?.viewControllers.first as? UITabBarController
    let tabBarHeight = tabBarController?.tabBar.frame.height ?? 0

    if #available(iOS 11.0, *), height > 0 {
        let safeAreaBottom = owningView?.safeAreaInsets.bottom ?? 0
        height -= safeAreaBottom + tabBarHeight
    }
    heightConstraint?.constant = height
    animate(notification)
    Keyboard.shared.currentHeight = height
}
s4cha commented 5 years ago

@bhavneet0812 Are you still experiencing the issue? I'm trying to reproduce the issue locally with no avail, I feel like it has been solved in the meantime :)