我不知道为什么会这样。。
当用户开始在文本字段中输入时,我正在尝试为我的视图设置动画。但该代码仅适用于横向左方向,但不适用于横向右...
这些方法在两个方向都被调用......
这是代码..
- (void)keyboardWasShown:(NSNotification *)aNotification {
if ( keyboardShown )
return;
NSTimeInterval animationDuration = 0.3;
CGRect frame = self.view.frame;
frame.size.width += 150;
[UIView beginAnimations:@"ResizeForKeyboard" context:nil];
[UIView setAnimationDuration:animationDuration];
self.view.frame = frame;
[UIView commitAnimations];
keyboardShown = YES;
}
- (void)keyboardWasHidden:(NSNotification *)aNotification {
NSTimeInterval animationDuration = 0.3;
CGRect frame = self.view.frame;
frame.size.width -= 150;
[UIView beginAnimations:@"ResizeForKeyboard" context:nil];
[UIView setAnimationDuration:animationDuration];
self.view.frame = frame;
[UIView commitAnimations];
keyboardShown = NO;
}
到目前为止,我刚刚对值进行了硬编码..