I have an UITextField
inside of a container view, when the keyboard pops up the container view disappears. In the same container view is a UICollectionView
, whose custom cells each contains a UITextField
and the keyboard works just fine for them.
I printed out the frame of the container view in the animation function that is called by keyboardWillShow
and the container view's frames are the same for both cases, so it looks like the container view just disappears (instead of "not moved" as i thought) when that specific UITextField
is selected. The relevant code is :
func keyboardWillShow(notification: NSNotification) {
if let userInfo = notification.userInfo {
if let keyboardSize = (userInfo[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
kbHeight = keyboardSize.height
self.animateDurationView(true)
}
}
}
func keyboardWillHide(notification: NSNotification) {
self.animateDurationView(false)
}
func animateDurationView(up: Bool) {
var movement = up ? -kbHeight : kbHeight
println(movement)
UIView.animateWithDuration(0.3, animations: {
self.durationView.frame = CGRectOffset(self.durationView.frame, 0, movement)
println(self.durationView.frame)
})
}
the screenshots can be found in this thread: KeyboardWillShow only moves container UIView for certain UITextFields
EDIT: at this point I am almost certain that it is the auto layout constraints that are screwing with me.