KeyboardManager
@available(iOSApplicationExtension, unavailable)
open class KeyboardManager : NSObject, UIGestureRecognizerDelegate
An object that observes keyboard notifications such that event callbacks can be set for each notification
-
A callback that passes a
KeyboardNotification
as an inputDeclaration
Swift
public typealias EventCallback = (KeyboardNotification) -> Void
-
A weak reference to a view bounded to the top of the keyboard to act as an
InputAccessoryView
but kept within the bounds of theUIViewController
s viewDeclaration
Swift
open weak var inputAccessoryView: UIView?
-
A flag that indicates if a portion of the keyboard is visible on the screen
Declaration
Swift
private(set) public var isKeyboardHidden: Bool { get }
-
A flag that indicates if the additional bottom space should be applied to the interactive dismissal of the keyboard
Declaration
Swift
public var shouldApplyAdditionBottomSpaceToInteractiveDismissal: Bool
-
Creates a
KeyboardManager
object an binds the view as fakeInputAccessoryView
Declaration
Swift
public convenience init(inputAccessoryView: UIView)
Parameters
inputAccessoryView
The view to bind to the top of the keyboard but within its superview
-
Creates a
KeyboardManager
object that observes the state of the keyboardDeclaration
Swift
public override init()
-
Declaration
Swift
required public init?(coder aDecoder: NSCoder)
-
Sets the
EventCallback
for aKeyboardEvent
Declaration
Swift
@discardableResult open func on(event: KeyboardEvent, do callback: EventCallback?) -> Self
Parameters
event
KeyboardEvent
callback
EventCallback
Return Value
Self
-
Constrains the
inputAccessoryView
to the bottom of its superview and sets the.willChangeFrame
and.willHide
event callbacks such that it mimics anInputAccessoryView
that is bound to the top of the keyboardDeclaration
Swift
@discardableResult open func bind(inputAccessoryView: UIView, withAdditionalBottomSpace additionalBottomSpace: (() -> CGFloat)? = .none) -> Self
Parameters
inputAccessoryView
The view to bind to the top of the keyboard but within its superview
Return Value
Self
-
Adds a
UIPanGestureRecognizer
to thescrollView
to enable interactive dismissal`Declaration
Swift
@discardableResult open func bind(to scrollView: UIScrollView) -> Self
Parameters
scrollView
UIScrollView
Return Value
Self
-
An observer method called last in the lifecycle of a keyboard becoming visible
Declaration
Swift
@objc open func keyboardDidShow(notification: NSNotification)
Parameters
notification
NSNotification
-
An observer method called last in the lifecycle of a keyboard becoming hidden
Declaration
Swift
@objc open func keyboardDidHide(notification: NSNotification)
Parameters
notification
NSNotification
-
An observer method called third in the lifecycle of a keyboard becoming visible/hidden
Declaration
Swift
@objc open func keyboardDidChangeFrame(notification: NSNotification)
Parameters
notification
NSNotification
-
An observer method called first in the lifecycle of a keyboard becoming visible/hidden
Declaration
Swift
@objc open func keyboardWillChangeFrame(notification: NSNotification)
Parameters
notification
NSNotification
-
An observer method called second in the lifecycle of a keyboard becoming visible
Declaration
Swift
@objc open func keyboardWillShow(notification: NSNotification)
Parameters
notification
NSNotification
-
An observer method called second in the lifecycle of a keyboard becoming hidden
Declaration
Swift
@objc open func keyboardWillHide(notification: NSNotification)
Parameters
notification
NSNotification
-
Starts with the cached
KeyboardNotification
and calculates a newendFrame
based on theUIPanGestureRecognizer
then calls the.willChangeFrame
EventCallback
actionDeclaration
Swift
@objc open func handlePanGestureRecognizer(recognizer: UIPanGestureRecognizer)
Parameters
recognizer
UIPanGestureRecognizer
-
Only receive a
UITouch
event when thescrollView
‘s keyboard dismiss mode is interactiveDeclaration
Swift
open func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool
-
Only recognice simultaneous gestures when its the
panGesture
Declaration
Swift
open func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool