Ios UIView在文本字段点击时隐藏

Ios UIView在文本字段点击时隐藏,ios,objective-c,iphone,uiview,Ios,Objective C,Iphone,Uiview,是我的UIViewController的结构,下面是问题场景 按添加栏按钮 名为“NewAddressView”(参考图像)的UIView将通过动画打开 - (IBAction)AddAddressAction:(id)sender { [UIView animateWithDuration:0.5 delay:0.1 options: UIViewAnimationOptionCurveEaseOut

是我的UIViewController的结构,下面是问题场景

  • 按添加栏按钮
  • 名为“NewAddressView”(参考图像)的UIView将通过动画打开

    - (IBAction)AddAddressAction:(id)sender {
    [UIView animateWithDuration:0.5
                      delay:0.1
                    options: UIViewAnimationOptionCurveEaseOut
                 animations:^{
                     self.NewAddressView.frame = CGRectMake(0, 0, 320, 460);
                 }
                 completion:^(BOOL finished){
                 }];
    }
    
    - (IBAction)CloseAddAddress:(id)sender {
    [UIView animateWithDuration:0.5
                      delay:0.1
                    options: UIViewAnimationOptionCurveEaseOut
                 animations:^{
                     self.NewAddressView.frame=CGRectMake(0,500,320,460);
                 }
                 completion:^(BOOL finished){
                 }];
    }
    
  • 此“NewAddressView”视图包含文本字段,如图所示

  • 点击文本字段时,“NewAddressView”会自动隐藏,不会编写额外代码来隐藏“NewAddressView”

  • 刚刚注意到,视图没有隐藏,而是移动到其原始位置,即CGRectMake(0500320460)。除了普通视图和文本字段,没有其他操作

  • 如果有什么需要补充的,请告诉我


    谢谢

    试着写下以下内容,将观点带到前面:

    [self.view bringSubviewToFront:self.NewAddressView];
    

    这里有点混乱。。。是否要隐藏
    NewAddressView
    或重新定位它?如果你想隐藏它,那么我在你的代码中看不到
    .hidden
    属性。也许你连接了一些插座错误?如果你想隐藏,请使用hidden属性!!!!!!我不想隐藏它,但想知道为什么它会移动到它的原始位置,CGRectMake(0500320460),因为当我点击文本字段时,它的位置是self.NewAddressView.frame=CGRectMake(0,0,320,460);那么为什么它会移回原来的位置呢?不,这只会使它位于顶部,但请注意NewAddressView的原来位置是self.NewAddressView.frame=CGRectMake(0500320460);从那里,动画出现在self.NewAddressView.frame=CGRectMake(0,0320460);点击添加新地址,点击文本字段,视图返回底部,这就是为什么它不返回到原始位置的问题。