由于某些原因,我的观点不是动画:
- (void)keyboardWillShow:(NSNotification*)aNotification
{
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
double duration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
int curve = [[info objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue];
int height = self.view.bounds.size.height - kbSize.height+self.tabBarController.tabBar.frame.size.height;
self.notesView.frame = CGRectMake(0, -height,
self.view.bounds.size.width, height);
[UIView animateWithDuration:1.5 delay:0 options:curve animations:^{
self.notesView.frame = CGRectMake(0, 0, self.view.bounds.size.width, height);
} completion:nil];
}
正在显示notesView
但未动画。当我将动画代码移动到btnPressed
方法时,它会按预期动画。有什么想法吗?
修改
看起来这个方法被调用了两次(这是一个处理inputAccessoryView
的单独问题,我仍然需要弄清楚)。我更新了它,看看只调用animateWithDuration
代码一次是否能解决问题。但是,它仍然没有动画。
- (void)keyboardWillShow:(NSNotification*)aNotification
{
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
int curve = [[info objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue];
int height = self.view.bounds.size.height - kbSize.height + self.tabBarController.tabBar.frame.size.height;
if (height == 510) return; //for some reason the self.view.bounds.size.height is different between the two calls
self.notesView.frame = CGRectMake(0, -height, self.view.bounds.size.width, height);
[UIView animateWithDuration:1.5 delay:0 options:curve animations:^{
self.notesView.frame = CGRectMake(0, 0, self.view.bounds.size.width, height);
} completion:nil];
}