Closed kiwo12345 closed 7 years ago
What you can do is to detect when the keyboard appears/disappears and modify your constraints manually. It is described in "Using keyboard observer directly" section of the readme:
https://github.com/exchangegroup/UnderKeyboard#using-keyboard-observer-directly
Thanks, and also thanks for sharing this library!
Like this?:
let keyboardObserver = UnderKeyboardObserver()
override func viewDidLoad() { super.viewDidLoad() keyboardObserver.start()
// Called before the keyboard is animated keyboardObserver.willAnimateKeyboard = { height in myConstraint.constant = MyCustomHeight }
// Called inside the UIView.animateWithDuration animations block keyboardObserver.animateKeyboard = { height in view.layoutIfNeeded() } }
Does this mean I only use UnderKeyboardObserver() instead of UnderKeyboardLayoutConstraint() ?
Yes, this is the code you can use. The implementation inside the two closures specific will be specific to your app.
And yes - in this case you do not need to use UnderKeyboardLayoutConstraint
class as you will be manipulating your auto layout constraints yourself.
Closing the issue. Feel free to reopen if needed.
Can I use this inside eg: textFieldDidBeginEditing() ?
I only want to toggle UnderKeyBoard on certain textFields and also use different contraints depending on what text field is being edited