I have the following code:
float yOffset = activeTextView.frame.origin.y - keyboardSize.height + 55;
CGPoint scrollPoint = CGPointMake(0.0, yOffset);
[scrollView setContentOffset:scrollPoint animated:YES];
This animates the scrollView in - (void)keyboardWasShown:(NSNotification *)notification
I am trying to return the scrollView to it’s original location after the hiding the keyboard like this:
- (void) keyboardWillHide:(NSNotification *)notification {
UIEdgeInsets contentInsets = UIEdgeInsetsZero;
scrollView.contentInset = contentInsets;
scrollView.scrollIndicatorInsets = contentInsets;
}
But it doesn’t work!
How can I return the UIScrollView and actually the whole screen to its original location so the user will see what he saw before animation of the scrollview?
In your
keyboardWasShown:method, you’re setting thecontentOffsetproperty ([scrollView setContentOffset:]is equivalent toscrollView.contentOffset). However, inkeyboardWillHide:, you’re settingcontentInset, which is something completely different (essentially, it’s the amount of internal padding of the scroll view’s content). Tryor
Also, as NSResponder mentioned, make sure your
keyboardWillHide:method is being called.