Supports Swift 3.0!
Represents a next responder UITextField. When the instance becomes first responder, and then the user taps the action button (e.g. return keyboard key) then one of the following happens:
- If no nextResponderField set, keyboard dismissed.
- If nextResponderField is a UIButton and disabled, then keyboard dismissed.
- If nextResponderField is a UIButton and enabled, then the UIButton fires touch up inside event (simulating a tap).
You can set nextResponderField to any UIResponder subclass, and it will become first responder when tapped. But having multiple NextResponderTextField pointing to each other, then you can go to next field.
The typical usage will be list of NextResponderTextField and the last one point to a UIButton.
For example a login screen: Username -> NextResponderTextField Password -> NextResponderTextField Sign In -> UIButton
Username.nextResponderField -> Password Password.nextResponderField -> Sign In
- iOS 7.0+ / Mac OS X 10.9+
- Xcode 8.0
- Swift 3.0
- Drag and drop a
UITextField
. - Change the class name to
NextResponderTextField
from identity inspector. - Change the Module name to
NextResponderTextField
from identity inspector. - Do the previous steps multiple times.
- Wire each field with the next one like that
- You can wire the last field with a UIButton to fire it.
Alternatively, you can create it from code just as you create a normal UITextField and set the nextResponderField property to the next UITextField or UIButton or even any UIResponder subclass.
You can set the keyboard "Return Key" to anything (Done, Next, etc.)
For iOS 8 or later:
NextResponderTextField is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "NextResponderTextField"
For iOS 7.x:
Embedded frameworks require a minimum deployment target of iOS 8.
To use NextResponderTextField with a project targeting iOS 7, you must include NextResponderTextField.swift directly into your project.
Mohamed Afifi, mohamede1945@gmail.com
NextResponderTextField is available under the MIT license. See the LICENSE file for more info.