美文网首页iOS 开发 iOS DeveloperiOS
稀有bug:当APP从后台进入前台时,键盘无法响应,输入不能

稀有bug:当APP从后台进入前台时,键盘无法响应,输入不能

作者: 静花寒 | 来源:发表于2016-04-22 17:07 被阅读367次

    bug并不是必现,在各种型号的机子上进行测试时,不同的机子,有的会有,有的不会有,为了解决这个问题,我也是头疼了好久,最终找到方法,可以调用UIApplicationDelegate class
    参考链接http://stackoverflow.com/questions/8072984/hittest-fires-when-uikeyboard-is-tapped

    此处做记录,丢完就跑

    - (void)applicationWillEnterForeground:(UIApplication *)application {
        // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
        for (UIWindow *testWindow in [UIApplication sharedApplication].windows) {
            if (!testWindow.opaque && [NSStringFromClass(testWindow.class) hasPrefix:@"UIText"]) {
                BOOL wasHidden = testWindow.hidden;
                testWindow.hidden = YES;
                
                if (!wasHidden) {
                    testWindow.hidden = NO;
                }
                
                break;
            }
        }
        
    }
    

    相关文章

      网友评论

        本文标题:稀有bug:当APP从后台进入前台时,键盘无法响应,输入不能

        本文链接:https://www.haomeiwen.com/subject/rbjxrttx.html