当textView
显示或隐藏键盘时,我正在使用波纹管代码向上或向下移动屏幕,通过这种方式,我可以在聚焦时看到最后一个字段。显示键盘时不显示导航栏
- (void)textViewDidBeginEditing:(UITextView *)textField
{
[self animateTextView: textField up: YES];
}
- (void)textViewDidEndEditing:(UITextView *)textField
{
[self animateTextView: textField up: NO];
}
- (void) animateTextView: (UITextView*) textField up: (BOOL) up
{
const int movementDistance = 130; // tweak as needed
const float movementDuration = 0.2f; // tweak as needed
int movement = (up ? -movementDistance : movementDistance);
[UIView beginAnimations: @"anim" context: nil];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration: movementDuration];
self.view.frame = CGRectOffset(self.view.frame, 0, movement);
[UIView commitAnimations];
}
但问题是,navBar
它也是移动时屏幕向上移动,在那里所有的移动除了navBar
或保持navBar
在它的使用[self animateTextView: textField up: YES];
后位置的方法吗?
为什么?你为什么要这样设计你的观点?为什么不使用'UINavigationController'?你为什么使用'beginAnimations:'API?这是什么,iOS/iPhoneOS 3? –