I am trying to scroll my UISCrollView when the keyboard is displayed
I use setContentOffset to switch uiview up.
At the same time, I want to reduce the height of my UISCrollView to (view height - keyboard height) so that I can scroll through the entire content view.
I apply as changes to the keyboard notification WillShow
When I actually bring the keyboard to my application, the content is first pushed up and then pushed down (which gives a flickering effect). I am trying to smooth both transforms at a time.
Is it possible?
Code below ---
- (void) keyboardWillShow { CGPoint contentOffset = scrollView.contentOffset; CGRect scrollViewFrame = scrollView.frame; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.3]; if (contentOffset.y >= 0 && contentOffset.x >= 0) { isContentOffset = YES; contentOffset.y += screenShift; [scrollView setContentOffset:contentOffset animated: NO]; } scrollViewFrame.size.height = keyboardOrigin.y - self.view.frame.origin.y - toolbarHeight; scrollView.frame = scrollViewFrame; [UIView commitAnimations]; }
source share