TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Nov 2016 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Michal Konturek.
Simplifies iOS keyboard handling.
Source code of this project is available under the standard MIT license. Please see the license file.
To use KeyboardController
, simply initialize it with an array of UITextField
objects.
let fields = [field1!, field2!, field3!, field4!, field5!]
self.controller = KeyboardController(fields: fields)
You can interact with KeyboardController
directly via the following methods:
func moveToNextField()
func moveToPreviousField()
func closeKeyboard()
KeyboardController
, depending on a returnKeyType
property of an UITextField
instance, will:
UIReturnKeyNext
- move to next text fieldUIReturnKeyDone
- close keyboardYou could also take advantage of delegation methods:
func controllerDidHideKeyboard(controller: KeyboardController)
func controllerDidShowKeyboard(controller: KeyboardController)
func controllerWillHideKeyboard(controller: KeyboardController)
func controllerWillShowKeyboard(controller: KeyboardController)
by setting a delegate
property of a KeyboardController
:
self.keyboardController.delegate = self;
There is also an option of setting a textFieldDelegate
property of all textFields that are under control of KeyboardController
:
self.keyboardController.textFieldDelegate = self;
This could be particulary useful if you would like to add individual behaviour to UITextFields
objects.
func textFieldDidBeginEditing(_ textField: UITextField) {
if (textField == self.field4) { self.moveViewBy(-10) }
if (textField == self.field5) { self.moveViewBy(-200) }
}
func textFieldDidEndEditing(_ textField: UITextField) {
if (textField == self.field4) { self.moveViewBy(10) }
if (textField == self.field5) { self.moveViewBy(200) }
}
git checkout -b new-feature
).git commit -am 'Added new-feature'
).git push origin new-feature
).