IQKeyboardManager 没有成员 sharedManager

IQKeyboardManager has no member sharedManager

我正在为我的 swift 4.0 项目使用 IQKeyboardManager pod。

IQKeyboardManager.sharedManager().enable = true

更新 pod 后,上述代码无效。

这是对您问题的回答:Type 'IQKeyboardManager' has no member 'sharedManager' by hackiftekhar

自 IQKeyboardManagerSwift 版本 6.0.0 起,sharedManager() 已替换为 shared

对于 pod 'IQKeyboardManagerSwift'pod 'IQKeyboardManagerSwift','6.0.0',试试这个:

IQKeyboardManager.shared.enable = true

看看这个:https://github.com/hackiftekhar/IQKeyboardManager/blob/master/IQKeyboardManagerSwift/IQKeyboardManager.swift


Swift Demo code by IQKeyboardManager


对于 pod 'IQKeyboardManagerSwift','5.0.0',试试这个

IQKeyboardManager.sharedManager().enable = true

使用这个 code.it 在 swift4 中完美运行。 安装吊舱文件。

pod 'IQKeyboardManager'

在 AppDelegate 中导入 IQKeyboardManager

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    IQKeyboardManager.shared().isEnabled = true

    return true
}

效果完美

取消选中仅适用于 IQKeyboardManager Pod 的允许应用程序扩展API。

点击 Pod -> IQkeyboardManager 获取 见下图