Now I found the solution. The animation starts from the point {0, 920}
to {0, 352}
. The problem was that the UITableView
object started with a size of {160, 568}
, so I changed the size of the UITableView
to {160, 920}
before the animation was started.
Concerning to the unknown animation curve, I just set the parameter to animationCurve << 16
to convert it from a view animation curve to a view animation option.
The value is not equal to the linear, ease in, ease out and ease inout animation curve.
Here is my code:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
and:
- (void)keyboardWillShow:(NSNotification *)aNotification {
NSDictionary *userInfo = aNotification.userInfo;
//
// Get keyboard size.
NSValue *beginFrameValue = userInfo[UIKeyboardFrameBeginUserInfoKey];
CGRect keyboardBeginFrame = [self.view convertRect:beginFrameValue.CGRectValue fromView:nil];
NSValue *endFrameValue = userInfo[UIKeyboardFrameEndUserInfoKey];
CGRect keyboardEndFrame = [self.view convertRect:endFrameValue.CGRectValue fromView:nil];
//
// Get keyboard animation.
NSNumber *durationValue = userInfo[UIKeyboardAnimationDurationUserInfoKey];
NSTimeInterval animationDuration = durationValue.doubleValue;
NSNumber *curveValue = userInfo[UIKeyboardAnimationCurveUserInfoKey];
UIViewAnimationCurve animationCurve = curveValue.intValue;
//
// Create animation.
CGRect tableViewFrame = self.tableView.frame;
bTableViewFrame.size.height = (keyboardBeginFrame.origin.y - tableViewFrame.origin.y);
self.tableView.frame = tableViewFrame;
void (^animations)() = ^() {
CGRect tableViewFrame = self.tableView.frame;
tableViewFrame.size.height = (keyboardEndFrame.origin.y - tableViewFrame.origin.y);
self.tableView.frame = tableViewFrame;
};
//
// Begin animation.
[UIView animateWithDuration:animationDuration
delay:0.0
options:(animationCurve << 16)
animations:animations
completion:nil];
}
UIViewController
with aUITableView
subview. – Chute