Declared in UIView+KeyboardHelpers.h

Overview

UIView (KeyboardHelpers) is a helper category that provides easy to use methods to manipulate views when the keyboard show/hide to avoid UITextField from getting covered by the keyboard.

Properties

animatedDistance

The distance that the UIView will animate when the keyboard is showing or hiding.

@property (nonatomic, retain) NSNumber *animatedDistance

Discussion

The default value should work. Don’t change it unless REALLY necessary.

Declared In

UIView+KeyboardHelpers.h

Instance Methods

checkTextField:

Checks if the provided object is a UITextField. If positive calls resignFirstResponder if the object is UIView calls resignTextFields:

- (void)checkTextField:(id)object

Parameters

object

The object that will be evaluated as a UITextField or UIView.

Declared In

UIView+KeyboardHelpers.h

cleanTextField:

Checks if the provided object is a UITextField. If positive sets the text property to @""; if the object is UIView calls resignTextFields:

- (void)cleanTextField:(id)object

Parameters

object

The object that will be evaluated as a UITextField or UIView.

Declared In

UIView+KeyboardHelpers.h

resignTextFields:

Iterates through the provided UIView container and calls resignFirstResponder if its a UITextField if not drills down on that object looking for more UITextField.

- (void)resignTextFields:(UIView *)container

Parameters

container

The UIView object that will be used as the “top” container to start drilling down looking for UITextField objects.

Discussion

This method calls down [UIView checkTextField:]

Declared In

UIView+KeyboardHelpers.h

slideDownIfNecessary

Detects if the UIView was moved up due to some keyboard covering it and slides it back to “normal”.

- (void)slideDownIfNecessary

Declared In

UIView+KeyboardHelpers.h

slideUpIfNecessaryForTextField:

Detects if the keyboard is going to cover the provided UITextField and slides up the UIView to avoid the it getting covered by the keyboard.

- (void)slideUpIfNecessaryForTextField:(UITextField *)textField

Parameters

textField

The UITextField object that needs to be checked if its going to be covered by the keyboard or not.

Declared In

UIView+KeyboardHelpers.h