Overview
IQActiveConfiguration is an internal class that coordinates keyboard state and active text input view information. It serves as the central coordination point between keyboard events, text input events, and the position adjustment logic in IQKeyboardManager.
Purpose
The active configuration class:- Monitors keyboard appearance, dismissal, and frame changes via
IQKeyboardNotification - Tracks which text input view is currently active via
IQTextInputViewNotification - Maintains the root view controller configuration state
- Coordinates animation timing between keyboard and view adjustments
- Manages the event lifecycle (show, change, hide)
Properties
keyboardInfo
- Keyboard visibility status (
isVisible) - Keyboard frame and bounds
- Animation duration and curve
Read-only property that returns the current keyboard information from the internal keyboard observer.
textInputView
The text input view that currently has focus, or
nil if no text input is active or if the active text input is within an alert view.textInputViewInfo
Comprehensive information about the active text input view, or
nil if no text input is active.rootConfiguration
Configuration object for the root view controller containing the active text input. Set automatically when a text input becomes active.
isReady
Returns
true when both a text input view is active and the root configuration is ready (view controller’s view is in a window).Event Lifecycle
The active configuration manages three types of events:Animation Coordination
animate(alongsideTransition:completion:)
Coordinates custom animations with the keyboard’s animation timing.transition: The animation block to execute alongside the keyboard animationcompletion: Optional completion handler called after the animation finishes
Observer Pattern
subscribe(identifier:changeHandler:)
Registers a change handler to be notified of configuration events.identifier: Unique identifier for the observer (used for unsubscribing)changeHandler: Closure called when events occur
unsubscribe(identifier:)
Removes a previously registered observer.Interactive Gesture Handling
The configuration includes special handling for interactive navigation gestures (swipe to go back). When an interactive pop gesture is detected:- Monitors the root controller’s frame changes
- Preserves keyboard and text input state during the gesture
- If the gesture is cancelled, restores the configuration
- If the gesture completes, properly cleans up the configuration
Orientation Change Handling
When the device orientation changes:- The configuration checks if the orientation has changed since initialization
- Updates the root controller configuration if needed
- Triggers appropriate events for position recalculation
- Restores previous state if the orientation returns to the original
Internal Architecture
Thread Safety
The entire class is marked with
@MainActor, ensuring all operations occur on the main thread. This is critical for UI updates and view hierarchy queries.Usage in IQKeyboardManager
TheIQKeyboardManager class maintains an internal instance:
See Also
- IQKeyboardManager - Main keyboard manager class
- IQRootControllerConfiguration - Root controller state tracking
- IQKeyboardNotification - Keyboard event observation
- IQTextInputViewNotification - Text input event observation