To run the example project, clone the repo, and run pod install from the Example directory first.
IQKeyboardCore is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'IQKeyboardCore'IQKeyboardCore is not intended to use independently. It's just a helper and extension for most of the IQKeyboard related libraries
This contains IQTextInputView protocol
@objc public protocol IQTextInputView where Self: UIView, Self: UITextInputTraits {
}UITextField, UITextView and UISearchBar are the known classes who adopted this protocol within the library
@objc extension UITextField: IQTextInputView {...}
@objc extension UITextView: IQTextInputView {...}
@objc extension UISearchBar: IQTextInputView {...}This library also contains IQEnableMode which is used by other libraries
@objc public enum IQEnableMode: Int {
case `default`
case enabled
case disabled
}There are other extension functions which are available on UIView
public extension IQKeyboardExtension where Base: UIView {
func viewContainingController() -> UIViewController?
func superviewOf<T: UIView>(type classType: T.Type, belowView: UIView? = nil) -> T?
func textFieldSearchBar() -> UISearchBar?
func isAlertViewTextField() -> Bool
}The viewContainingController() function intelligently traverses the responder chain to find the appropriate view controller, preferring content view controllers over container view controllers. For example:
- When a text field is inside a UINavigationController, it returns the top view controller instead of the navigation controller itself
- When a text field is inside a UITabBarController, it returns the selected view controller
- When a text field is inside a UISplitViewController, it returns the primary view controller
- When a text field is inside a UIPageViewController, it returns the current view controller
The textFieldSearchBar() function also intelligently traverses the responder chain to find UISearchBar instances, properly handling container view controllers. It continues searching through navigation controllers, tab bar controllers, split view controllers, and page view controllers to find search bars that might be contained within their managed view controllers.
Above extension functions can be used like below
view.iq.viewContainingController()
view.iq.superviewOf(type: UIScrollView.self)
view.iq.textFieldSearchBar()
view.iq.isAlertViewTextField()hackiftekhar, ideviftekhar@gmail.com
IQKeyboardCore is available under the MIT license. See the LICENSE file for more info.