I scroll through the UIScrollView until the keyboard hides the UITextField. I reduce the height of the UIScrollView if it is closed, which works fine. but when I try to grow a UIScrollView heigh (back to the original size), the whole UIScrollView moves up and then animates to its original size and location. the origin increases by X and moves down to where it should be instead of the height of the drop-down view.
- (void)keyboardWillShow:(NSNotification *)n
{
keyboardMove = self.rightScrollView.frame;
offsetMove = self.rightScrollView.contentOffset;
NSDictionary* userInfo = [n userInfo];
CGSize keyboardSize = [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
[UIView animateWithDuration:.25
delay:0
options:(UIViewAnimationOptionAllowUserInteraction)
animations:^
{
self.rightScrollView.frame = CGRectMake(self.rightScrollView.frame.origin.x, self.rightScrollView.frame.origin.y, self.rightScrollView.frame.size.width, (self.view.frame.size.height - (self.rightScrollView.frame.origin.y + keyboardSize.height)));
}
completion:nil];
if ((activeTextField.frame.origin.y + activeTextField.frame.size.height) > self.rightScrollView.frame.size.height)
{
float contentOffsetMove = (self.rightScrollView.contentOffset.y + (activeTextField.frame.origin.y - self.rightScrollView.frame.size.height) + activeTextField.frame.size.height + 10);
self.rightScrollView.contentOffset = CGPointMake(self.rightScrollView.contentOffset.x, contentOffsetMove);
}
}
- (void)keyboardWillHide:(NSNotification *)n
{
if ((activeTextField.frame.origin.y + activeTextField.frame.size.height) > self.rightScrollView.frame.size.height)
{
[UIView animateWithDuration:.25
delay:0
options:(UIViewAnimationOptionAllowUserInteraction)
animations:^{
[self.rightScrollView setContentOffset:offsetMove animated:YES];
self.rightScrollView.frame = keyboardMove;
}
completion:nil];
}
else
{
[UIView animateWithDuration:.25
delay:0
options:(UIViewAnimationOptionAllowUserInteraction)
animations:^{
self.rightScrollView.frame = keyboardMove;
}
completion:nil];
}
}
therefore, when the keyboard is hiding, self.rightScrollView.origin moves up the X points and then animates at that location. I need the source to stay in place and the height to be larger (growing down).
any ideas why he is behaving with a spirit?