4
6

More than 1 year has passed since last update.

IQKeyboardManagerを使用する際、特定の画面のみ機能を無効にする

Posted at

IQKeyboardManagerはとても便利なライブラリですが、他UIライブラリとの相性が悪く思い通りに動作しないことがあります。

MessageKitというライブラリを使用した際に、IQKeyboardManagerの機能が有効だったためUI周りの挙動がうまく制御できませんでした。そこでIQKeyboardManagerのdisabledDistanceHandlingClassesを使用し特定の画面のみライブラリの機能が無効になるよう設定しました。

AppDelegate didFinishLaunchingWithOptions()内に無効化する処理を追加する

IQKeyboardManager.shared.disabledDistanceHandlingClasses.append(xxx.self)

func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        IQKeyboardManager.shared.enable = true
        IQKeyboardManager.shared.disabledDistanceHandlingClasses.append(xxx.self)
        return true
    }

簡単に特定の画面のみIQKeyboardManagerの機能を無効化できました。
他UI系ライブラリとバッティングする場合は状況に応じて無効化すると良さそうです。
お粗末さまでした。

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6