How to hide Toolbar in IQKeyboardManager iOS Swift 3

后端 未结 10 2092
南笙
南笙 2021-01-12 09:35

I\'m using the IQKeyboardManger library to scroll text fields when started typing using the keyboard, but I don\'t want to display the default toolbar from their library. Be

相关标签:
10条回答
  • 2021-01-12 09:57

    You can enable or disable the toolbar in didFinishLaunchingWithOptions of AppDelegate:

    IQKeyboardManager.shared.enable = true
    
    IQKeyboardManager.shared.enableAutoToolbar = false
    

    For more info see Properties and functions usage

    0 讨论(0)
  • 2021-01-12 09:58

    This is the way to do it for an individual view controller:

    class YourViewController: UIViewController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            IQKeyboardManager.shared.disabledToolbarClasses = [YourViewController.self]
        }
    }
    

    And to prevent the vc from rising when IQKeyboardManager raises it when the keyboard is present:

    IQKeyboardManager.shared.disabledDistanceHandlingClasses.append(YourViewController.self)
    
    0 讨论(0)
  • 2021-01-12 10:03

    Swift 5, IQKeyboardManager (6.3.0)

    You can call this setup function from your didFinishLaunchingWithOptions in the app delegate:

    private func setupKeyboardManager() {
        IQKeyboardManager.shared().isEnabled = true
        IQKeyboardManager.shared().isEnableAutoToolbar = false
        IQKeyboardManager.shared().shouldShowToolbarPlaceholder = false
        IQKeyboardManager.shared().previousNextDisplayMode = .alwaysHide
    }
    

    Feel free to add any other customisation you need in this method, such as shouldResignOnTouchOutside or similar.

    0 讨论(0)
  • 2021-01-12 10:04

    Swift 5.1, Xcode 11

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
        IQKeyboardManager.shared.enable = true
        IQKeyboardManager.shared.enableAutoToolbar = false
        IQKeyboardManager.shared.shouldShowToolbarPlaceholder = false
        IQKeyboardManager.shared.shouldResignOnTouchOutside = true
    
        return true
    }
    
    0 讨论(0)
提交回复
热议问题