iosswiftiqkeyboardmanager

IQKeyboardManager Swift Does Not Work At All


as the title says, I'm attempting to fix up this project given to me and they use IQSharedKeyboard which from what I've read is supposed to be great. The problem is that it doesn't work, at all. It pushes my top header up whenever it does try to work, and it only shows up on the bottom 2% of the screen, like all I see is the Done toolbar. How can I fix this? Google yields no results, maybe there's a newer library? My views as far as I'm aware are all scrolling/UIView/UIText views so it really shouldn't be an issue. I also am not sure why it pushes my top header up, but that's a separate question for after it actually works. Debug Code:

IQKeyboardManager|  ⌨️>>>>> keyboardWillHide(_:) started >>>>>
IQKeyboardManager|  |   Notification Object:<UIScreen: 0x7f9519d04a40; bounds: {{0, 0}, {393, 852}}; mode: <UIScreenMode: 0x6000029f3fa0; size = 1179.000000 x 2556.000000>>
IQKeyboardManager|  ⌨️<<<<< keyboardWillHide(_:) ended: 0.00040386100590694696 seconds <<<<<
IQKeyboardManager|  ⌨️>>>>> keyboardDidHide(_:) started >>>>>
IQKeyboardManager|  |   Notification Object:<UIScreen: 0x7f9519d04a40; bounds: {{0, 0}, {393, 852}}; mode: <UIScreenMode: 0x6000029f3fa0; size = 1179.000000 x 2556.000000>>
IQKeyboardManager|  ⌨️<<<<< keyboardDidHide(_:) ended: 8.349800191354007e-05 seconds <<<<<
IQKeyboardManager|  UIKeyboard Frame: (0.0, 808.0, 393.0, 119.0)
IQKeyboardManager|  ⌨️>>>>> keyboardWillShow(_:) started >>>>>
IQKeyboardManager|  |   Notification Object:<UIScreen: 0x7f9519d04a40; bounds: {{0, 0}, {393, 852}}; mode: <UIScreenMode: 0x6000029f3fa0; size = 1179.000000 x 2556.000000>>
IQKeyboardManager|  |   Saving <YACHT_NOW.ChatRoomView: 0x7f9518847e00> beginning origin: (0.0, 0.0)
IQKeyboardManager|  ⌨️<<<<< keyboardWillShow(_:) ended: 0.0001746119960444048 seconds <<<<<
IQKeyboardManager|  >>>>> adjustPosition() started >>>>>
IQKeyboardManager|  |   Need to move: 26.0
IQKeyboardManager|  |   Moving Upward
IQKeyboardManager|  |   Set <YACHT_NOW.ChatRoomView: 0x7f9518847e00> origin to: (0.0, -26.0)
IQKeyboardManager|  <<<<< adjustPosition() ended: 0.0005378810019465163 seconds <<<<<
IQKeyboardManager|  ⌨️>>>>> keyboardDidShow(_:) started >>>>>
IQKeyboardManager|  |   Notification Object:<UIScreen: 0x7f9519d04a40; bounds: {{0, 0}, {393, 852}}; mode: <UIScreenMode: 0x6000029f3fa0; size = 1179.000000 x 2556.000000>>
IQKeyboardManager|  ⌨️<<<<< keyboardDidShow(_:) ended: 0.00013294999371282756 seconds <<<<<
IQKeyboardManager|  >>>>> adjustPosition() started >>>>>
IQKeyboardManager|  |   Need to move: 0.0
IQKeyboardManager|  <<<<< adjustPosition() ended: 6.623199442401528e-05 seconds <<<<<
IQKeyboardManager|  ⌨️>>>>> keyboardWillHide(_:) started >>>>>
IQKeyboardManager|  |   Notification Object:<UIScreen: 0x7f9519d04a40; bounds: {{0, 0}, {393, 852}}; mode: <UIScreenMode: 0x6000029f3fa0; size = 1179.000000 x 2556.000000>>
IQKeyboardManager|  |   Restoring <YACHT_NOW.ChatRoomView: 0x7f9518847e00> origin to: (0.0, 0.0)
IQKeyboardManager|  ⌨️<<<<< keyboardWillHide(_:) ended: 0.00037055999564472586 seconds <<<<<
IQKeyboardManager|  📝>>>>> textFieldViewDidEndEditing(_:) started >>>>>
IQKeyboardManager|  |   Notification Object:<YACHT_NOW.CustomChatTextField: 0x7f951a09f600; baseClass = UITextView; frame = (10 6; 244 30); clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x6000026dcfc0>; backgroundColor = <UIDynamicSystemColor: 0x600003cb61c0; name = systemBackgroundColor>; layer = <CALayer: 0x600002951b80>; contentOffset: {0, 0.33333333333333331}; contentSize: {244, 33}; adjustedContentInset: {0, 0, 0, 0}>
IQKeyboardManager|  📝<<<<< textFieldViewDidEndEditing(_:) ended: 0.00011827600246760994 seconds <<<<<
IQKeyboardManager|  ⌨️>>>>> keyboardDidHide(_:) started >>>>>
IQKeyboardManager|  |   Notification Object:<UIScreen: 0x7f9519d04a40; bounds: {{0, 0}, {393, 852}}; mode: <UIScreenMode: 0x6000029f3fa0; size = 1179.000000 x 2556.000000>>
IQKeyboardManager|  ⌨️<<<<< keyboardDidHide(_:) ended: 0.00021278900385368615 seconds <<<<<

Code for messaging

extension ChatRoomView : UITextViewDelegate {
    func textViewDidBeginEditing(_ textView: UITextView) {
        if textView.text == "Type here" {
            textView.text = ""
            //textView.textColor = UIColor.darkGray
        }
    }
    
    func textViewDidEndEditing(_ textView: UITextView) {
        if textView.text.isEmpty {
            
            textView.text = "Type here"
            //textView.textColor = UIColor.lightGray
        }
    }
}

Solution

  • you can reinstall pod -> pod 'IQKeyboardManager'

    make sure you import -> import IQKeyboardManagerSwift , in AppDelegate.swift file in your app

    make sure you set keyboard in didFinishLaunchingWithOptions function of AppDelegate.swift -> IQKeyboardManager.shared.enable = true

    pod 'IQKeyboardManager'
    
    import IQKeyboardManagerSwift
    
    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
    
        var window: UIWindow?
    
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
          IQKeyboardManager.shared.enable = true
    
          return true
        }
    }