Skip to main content
Get started with IQKeyboardManager in just a few simple steps. This guide will have your keyboard management working in less than 5 minutes.

Prerequisites

Make sure you’ve installed IQKeyboardManager using CocoaPods, SPM, or Carthage.

Setup Guide

1

Import the Framework

Open your AppDelegate.swift file and import IQKeyboardManager at the top:
AppDelegate.swift
import UIKit
import IQKeyboardManagerSwift

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    // ...
}
For SwiftUI apps with the @main App struct, you can use init() instead of AppDelegate. See the Basic Setup guide for details.
2

Enable IQKeyboardManager

In the application(_:didFinishLaunchingWithOptions:) method, enable the manager:
AppDelegate.swift
func application(_ application: UIApplication, 
                 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
    // Enable IQKeyboardManager
    IQKeyboardManager.shared.isEnabled = true
    
    return true
}
That’s it! Your keyboard will now automatically avoid covering text fields.
This is the minimal setup. The keyboard distance will automatically adjust for all UITextField and UITextView instances in your app.
3

Optional: Configure Additional Features

Customize IQKeyboardManager with additional options based on your needs:
Configure keyboard distance and enable debugging:
AppDelegate.swift
func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
    // Enable keyboard management
    IQKeyboardManager.shared.isEnabled = true
    
    // Set keyboard distance from text field (default is 10.0)
    IQKeyboardManager.shared.keyboardDistance = 20.0
    
    // Enable debug mode to see console logs
    IQKeyboardManager.shared.isDebuggingEnabled = true
    
    return true
}
4

Verify It Works

Build and run your app:
  1. Navigate to any screen with a UITextField or UITextView
  2. Tap on the text field to bring up the keyboard
  3. 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 enabled isDebuggingEnabled, check the console for helpful logs:
IQKeyboardManager: Enabled
IQKeyboardManager: Keyboard will show
IQKeyboardManager: Adjusting position for MyViewController
IQKeyboardManager: Distance from keyboard: 20.0

Per-View Configuration

You can override global settings for specific text fields:
// Set custom keyboard distance for a specific text field
myTextField.iq.distanceFromKeyboard = 50.0

Thread Safety Note

All IQKeyboardManager APIs must be called from the main thread.
The library uses @MainActor to enforce this at compile time:
// ✅ Correct - called on main thread
func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    IQKeyboardManager.shared.isEnabled = true
    return true
}

// ❌ Wrong - don't call from background thread
DispatchQueue.global().async {
    IQKeyboardManager.shared.isEnabled = true  // Compiler error
}

Common Configuration Options

Here are the most commonly used configuration properties:
PropertyTypeDefaultDescription
isEnabledBoolfalseEnable/disable keyboard management globally
keyboardDistanceCGFloat10.0Distance between keyboard and text field
resignOnTouchOutsideBoolfalseDismiss keyboard when tapping outside
layoutIfNeededOnUpdateBoolfalseForce layout update on keyboard show
isDebuggingEnabledBoolfalseEnable console logging for debugging
See the Configuration Guide for a complete list of available options.

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

Build docs developers (and LLMs) love