在iOS 7上的viewDidDisappear之后,键盘不会消失 [英] Keyboard does not disappear after viewDidDisappear on iOS 7

查看:144
本文介绍了在iOS 7上的viewDidDisappear之后,键盘不会消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的应用程序中,有一种情况是用户在文本框中输入内容然后按后退按钮返回主屏幕。

In our app, there's a situation where the user enters something in a textbox and then presses the back button to go back to the master screen.

如果我们运行在iOS 7上,键盘不会消失,它只会停留在那里。用户仍然可以浏览应用程序,但所有文本字段都被禁用,这意味着您无法在任何地方输入文本。用户唯一的选择就是杀死应用并重新开始。

If we run that on iOS 7, the keyboard does not disappear, it just stays there. The user can still navigate through the app, but all text fields are disabled, meaning you can't enter text anywhere. The only option the user has is killing the app and starting fresh.

我们尝试添加 resignFirstResponder 消息,但是这没有任何帮助。

We tried to add resignFirstResponder messages, but that didn't help anything.

涉及的代码很多,我们正在积极解决这个问题。与此同时,有没有人遇到过这个问题,也许还有办法让它消失?

There's much code involved, and we're actively working on the issue. Meantime, has anyone experienced that problem too, and maybe found a way to make it go away?

推荐答案

<当我为iOS 7编译应用程序时,我遇到了和你一样的问题,我做了以下更改:

I had the same issue like you when I compiled the app for iOS 7 and I did the following changes:


  1. 制作确保在解除viewController之前添加 [textfield resignFirstResponder] ,例如:

[_passwordInput resignFirstResponder];
[_emailInput resignFirstResponder];
[self performSegueWithIdentifier:@"forgotPassword" sender:self];


  • 为了确保键盘消失,请添加 [textfield resignFirstResponder] in viewWillDisappear 例如:

    - (void) viewWillDisappear:(BOOL)animated
    {
       [_passwordInput resignFirstResponder];
       [_emailInput resignFirstResponder];
    }
    


  • 如果你的viewController是使用 UIModalPresentationFormSheet呈现的将此添加到您的viewController只是为了确保文本字段将响应 resignFirstResponder

  • If your viewController is presented using UIModalPresentationFormSheet add this to your viewController just to make sure the textfields will respond resignFirstResponder:

    - (BOOL)disablesAutomaticKeyboardDismissal
    {
       return NO;
    }
    


  • 在您的情况下,覆盖后退按钮操作或只需使用 viewWillDisappear 来检查用户何时按下后退按钮然后在<之前调用 resignFirstResponder code> [super viewWillDisappear] 类似这样的事情:

    In your case, override the back button action or just use viewWillDisappear to check when the user pressed the back button and then call resignFirstResponder before [super viewWillDisappear] something like this:

    -(void) viewWillDisappear:(BOOL)animated 
    {
       [_passwordInput resignFirstResponder];
       [_emailInput resignFirstResponder];
       [super viewWillDisappear:animated];
    }
    

    这篇关于在iOS 7上的viewDidDisappear之后,键盘不会消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆