How to hide Toolbar in IQKeyboardManager iOS Swift 3
You can set IQKeyboardManager below properties.
I assume you have enabled the IQKeyboardManager in didFinishLaunch of app delegate like this
IQKeyboardManager.sharedManager().enable = true
shouldShowTextFieldPlaceholder to false
==> If you want to hide placeholder toolbar section
shouldHidePreviousNext to false
==> If you want to hide next and prev button and so on.
You can enable the settings in didFinishLaunch of AppDelegate like this
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
IQKeyboardManager.sharedManager().enable = true
IQKeyboardManager.sharedManager().enableAutoToolbar = false
IQKeyboardManager.sharedManager().shouldShowTextFieldPlaceholder = false
IQKeyboardManager.sharedManager().shouldHidePreviousNext = false
return true
}
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
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)
Swift 3
You must use shouldResignOnTouchOutside
to resign textField if touched outside of UITextField
/UITextView
.
Add this in your ViewController
if you want it in an specific ViewController
or to override all your application in the file AppDelegate
.
Inside the method:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
IQKeyboardManager.sharedManager().enable = true
IQKeyboardManager.sharedManager().enableAutoToolbar = false
IQKeyboardManager.sharedManager().shouldShowToolbarPlaceholder = false
IQKeyboardManager.sharedManager().shouldResignOnTouchOutside = true
}