Ios 显示键盘时导航栏不可见

Ios 显示键盘时导航栏不可见,ios,objective-c,navbar,Ios,Objective C,Navbar,当textView显示或隐藏键盘时,我使用下面的代码向上或向下移动屏幕,这样我可以在聚焦时看到最后一个字段 - (void)textViewDidBeginEditing:(UITextView *)textField { [self animateTextView: textField up: YES]; } - (void)textViewDidEndEditing:(UITextView *)textField { [self animateTextView: text

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];
}

但问题是
导航栏
在屏幕向上移动时也会移动,是否有办法移动除
导航栏
之外的所有导航栏,或者在使用
[自动画特写视图:文本字段向上:是]后将
导航栏保持在其位置

这是因为在主视图中有自定义导航栏。 在序列图像板中的导航栏下方创建另一个UI视图,然后将文本字段和其他UI对象放置在此新视图中。 请记住,当键盘出现时,导航栏不应位于向上推动的同一UIView对象的一侧。 因此,为这个新创建的UIView对象创建一个出口,而不是移动viewController的主视图,只需像这样设置新创建的视图

[UIView animateWithDuration:0.2 animations:^{
    //Just Replace Your Animation Code with This and see the difference.
    self.containerViewOfOtherObjects.frame = CGRectOffset(self.containerViewOfOtherObjects.frame, 0, movement);
}];

谢谢Syed,我已经添加了,我是否需要只替换行
self.view.frame=CGRectOffset(self.view.frame,0,movement)由在答案中张贴的?或者也删除
[UIView beginAnimations:@“anim”上下文:nil]…否。就这一行<代码>self.view.frame=CGRectOffset(self.view.frame,0,移动)我已经尝试过了,但这就像是快速上移和下移一样,新添加的视图位于其原始位置让我添加一些东西。用这些平滑动画的代码行替换我的代码
[UIView beginAnimations:@“anim”context:nil];[UIView setAnimationBeginsFromCurrentState:是];[UIView setAnimationDuration:movementDuration];self.view.frame=CGRectOffset(self.view.frame,0,移动);[UIView委员会]为什么?你为什么要这样设计你的视图?为什么不使用
UINavigationController
?为什么要使用
beginAnimations:
API?这是什么,iOS/iphoneos 3?