Prerequisites
Make sure you’ve installed IQKeyboardManager using CocoaPods, SPM, or Carthage.
Setup Guide
Import the Framework
Open your
AppDelegate.swift file and import IQKeyboardManager at the top:AppDelegate.swift
For SwiftUI apps with the
@main App struct, you can use init() instead of AppDelegate. See the Basic Setup guide for details.Enable IQKeyboardManager
In the That’s it! Your keyboard will now automatically avoid covering text fields.
application(_:didFinishLaunchingWithOptions:) method, enable the manager:AppDelegate.swift
Optional: Configure Additional Features
Customize IQKeyboardManager with additional options based on your needs:
- Basic Configuration
- With Toolbar
- With Tap to Dismiss
- All Features
Configure keyboard distance and enable debugging:
AppDelegate.swift
Verify It Works
Build and run your app:
- Navigate to any screen with a UITextField or UITextView
- Tap on the text field to bring up the keyboard
- Notice how the view automatically adjusts to keep the text field visible
Success! Your text fields should never be covered by the keyboard again.
What to Look For
- The view automatically scrolls when a text field is focused
- Text fields near the bottom of the screen remain visible
- Works in all orientations (portrait and landscape)
- No code changes needed in your view controllers
Debug Mode (Optional)
If you enabledisDebuggingEnabled, check the console for helpful logs:Per-View Configuration
You can override global settings for specific text fields:Thread Safety Note
The library uses@MainActor to enforce this at compile time:
Common Configuration Options
Here are the most commonly used configuration properties:| Property | Type | Default | Description |
|---|---|---|---|
isEnabled | Bool | false | Enable/disable keyboard management globally |
keyboardDistance | CGFloat | 10.0 | Distance between keyboard and text field |
resignOnTouchOutside | Bool | false | Dismiss keyboard when tapping outside |
layoutIfNeededOnUpdate | Bool | false | Force layout update on keyboard show |
isDebuggingEnabled | Bool | false | Enable console logging for debugging |
What’s Next?
Now that you have IQKeyboardManager working, explore more advanced features:Core Configuration
Learn about all available configuration options and customization
Toolbar Management
Customize the toolbar with Previous/Next/Done buttons
Advanced Configuration
Override settings for specific views or view controllers
API Reference
Explore the complete API documentation