contentInset set to 0 in NavigationController provoking content to be under navigation bar
When working with a NavigationController in a storyboard with a rootView and a secondView (push segue) both with TPKeyboardAvoidingScrollView when you get to the secondView TPKeyboardAvoiding_keyboardWillShow [UIScrollView+TPKeyboardAvoidingAdditions] is still called in the rootView so it causes later for the rootView to be under the navigation bar as it sets its contentInset.top to 0.
I fixed it this way:
In TPKeyboardAvoiding_keyboardWillShow method from [UIScrollView+TPKeyboardAvoidingAdditions] :
Original code:
UIView *firstResponder = [self TPKeyboardAvoiding_findFirstResponderBeneathView:self];
Changed code:
UIView *firstResponder = [self TPKeyboardAvoiding_findFirstResponderBeneathView:self];
if(!firstResponder) {
return;
}
thanks for this – worked like a charm for me in a similar situation. A UINavigationController containing viewControllers [A, B], where B is the top view controller, a text field in B was active, and then the back button was pushed. When popped back to A, the content offset was consistently being pushed -44 up, which let to annoying results
Thanks! I had exactly the same problem as jpohh and changing the code in TPKeyboardAvoiding_keyboardWillShow as fabianz66 described fixed it. However I'm using xib's with autolayout instead of storyboard.
I still have this problem. Is there another approach to fix it?