Latest0.0.9
Homepagehttps://github.com/QuantumKing/QKForms
LicenseMIT
Platformsios 5.0, requires ARC
Authors

Automatically handles moving text fields and text views out of the way of the keyboard. Also handles expanding text views to fit their text. Device orientation agnostic.

QKForms in action!

QKForms

Usage

Here is a step by step guide to using QKForms with interface builder. The demo these steps refer to is included in QKFormsDemo.

Step 1

Create a scroll view (or table view, or collection view) and add the QKFormsScrollView class to it.

QKForms

Step 2

If you want a text view which expands and moves out of the way of the keyboard as you type, then add the QKAutoExpandingTextView class to your text view.

QKForms

Step 3

Add any number of text fields, searchbars, all inside another view, whatever!

QKForms

That’s it!

Everything is handled automatically after you’ve designed your form. Any text view with the class QKAutoExpandingTextView will expand as you type:

QKForms

and the class QKFormsScrollView handles moving its text fields and text views out of the way of the keyboard. It also handles hiding the keyboard whenever it receives a tap gesture.

QKForms

Options

Each of QKFormsScrollView, QKFormsTableView and QKFormsCollectionView comes with the following interface:

// Options, which can be found in the QKFormsOptions class.
@property (nonatomic, readonly) QKFormsOptions *options;

// An optional property which will be sent the TouchUpInside event
// when return is pressed while editing the last field in the form.
// The options property returnShouldMoveToNextField must be set to YES in order
// to use this.
@property (nonatomic, weak) IBOutlet UIButton *submitButton;

// Navigates to the next field, based on vertical position.
- (IBAction)nextField;

// Navigates to the previous field, based on vertical position.
- (IBAction)previousField;

- (IBAction)dismissKeyboard;
- (void)dismissKeyboardWithCompletion:(void (^)(void))completion;

There are a few options that you may set through QKFormsOptions:

// Whether return navigates to the next field or not.
// Default: YES
@property (nonatomic, assign) BOOL returnShouldMoveToNextField;

// In text views, whether return should insert a newline character.
// This overrides returnShouldMoveToNextField for text views.
// Default: NO
@property (nonatomic, assign) BOOL returnShouldInsertNewline;

// The margin between the keyboard and the field being edited.
// Default: 20
@property (nonatomic, assign) CGFloat keyboardTopMargin;

// Whether the form view displays a shadow when its content overflows.
// In order for this to work, this view must have a superview with the same bounds.
// Default: YES
@property (nonatomic, assign) BOOL showsShadow;

// This will force the field to be pulled down towards the keyboard, even
// if it is already above the keyboard.
// Default: NO
@property (nonatomic, assign) BOOL shouldFocusFields;

QKForms provides a subclass of UITextView called QKAutoExpandingTextView which handles automatically expanding itself to fit the text its given. It can also have a maximum height set:

// If maxHeight is a number other than 0, this view will not expand beyond maxHeight.
@property (nonatomic, assign) CGFloat maxHeight;

Another useful view called QKPlaceholderTextView, which is a subclass of QKAutoExpandingTextView, allows for placeholder text to be set on a text view.

Installation via Cocoapods

Add pod 'QKForms', '~> 0.0' to your Podfile and run pod to install.

Latest podspec

{
    "name": "QKForms",
    "version": "0.0.9",
    "summary": "Move text fields and text views out of the way of the keyboard and expand text views to fit their text. Device orientation agnostic.",
    "description": "                   A longer description of QKForms in Markdown format.nn                   * Think: Why did you write this? What is the focus? What does it do?n                   * CocoaPods will be using this to generate tags, and improve search results.n                   * Try to keep it short, snappy and to the point.n                   * Finally, don't worry about the indent, CocoaPods strips it!n",
    "homepage": "https://github.com/QuantumKing/QKForms",
    "screenshots": "https://raw.githubusercontent.com/QuantumKing/QKForms/master/QKFormsDemo/screenshots/textview.png",
    "license": {
        "type": "MIT",
        "file": "license.txt"
    },
    "authors": {
        "Eric Webster": "[email protected]"
    },
    "platforms": {
        "ios": "5.0"
    },
    "source": {
        "git": "https://github.com/QuantumKing/QKForms.git",
        "tag": "v0.0.9"
    },
    "source_files": [
        "QKForms/*.{h,m}",
        "QKForms/Categories/*.{h,m}"
    ],
    "requires_arc": true
}

Pin It on Pinterest

Share This