[[UIApplication sharedApplication].keyWindow setWindowLevel:UIWindowLevelStatusBar];
UIView *staView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 20)];
staView.backgroundColor = [UIColor redColor];
[[UIApplication sharedApplication].keyWindow addSubview:staView];
_topWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 20)];
[_topWindow setBackgroundColor:[UIColor clearColor]];
[_topWindow setWindowLevel:UIWindowLevelStatusBar];
这时同样设置了WindowLevel级别为UIWindowLevelStatusBar,还是会出现第二种的键盘被隐藏的情况
一、原因分析:
通常是由于程序中除AppDelegate中的UIWindow以外又定义了其他的UIWindow,并使用了[XXwindow makeKeyAndVisible]方法将自定义的UIWindow表示在画面最前端,
从而影响到了程序中其他UIWebView中的响应。
二、解决方法:
通常在脱离自定义UIWindow的响应范围的时候(比如某个画面的viewWillDisappear事件里),将AppDelegate中的UIWindow重新放回到最前端即可。
XXXAppDelegate *appDelegate = (XXXAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.window makeKeyAndVisible];