Cocoa touch 在应用程序标识符背景中隐藏键盘:-屏幕截图问题

Cocoa touch 在应用程序标识符背景中隐藏键盘:-屏幕截图问题,cocoa-touch,ios,animation,ios4,keyboard,Cocoa Touch,Ios,Animation,Ios4,Keyboard,当按下home(主页)按钮时,我想隐藏键盘并将视图恢复到正常状态,这样当应用程序再次启动/预支时,就不会选择文本字段,键盘也会隐藏 My app delegate具有此方法的实现: - (void)applicationDidEnterBackground:(UIApplication *)application { [tabBarController.view endEditing:YES]; } 键盘确实被移除了,但我不明白的是:苹果的文档说,在方法返回后会拍摄应用程序的快照。但是

当按下home(主页)按钮时,我想隐藏键盘并将视图恢复到正常状态,这样当应用程序再次启动/预支时,就不会选择文本字段,键盘也会隐藏

My app delegate具有此方法的实现:

- (void)applicationDidEnterBackground:(UIApplication *)application {
    [tabBarController.view endEditing:YES];
}
键盘确实被移除了,但我不明白的是:苹果的文档说,在方法返回后会拍摄应用程序的快照。但是,这会对键盘向下滑动动画造成问题。有时,当应用程序再次启动一小段时间时,键盘会显示一半。我假设截图是在动画完成之前拍摄的


要解决这个问题,我应该怎么做,在
applicationidenterbackground:
方法中引入一个短定时器?我想知道是否有“更干净”的解决方案。

我没有尝试过这个方法,但是在您退出键盘之前关闭动画怎么样:

- (void)applicationDidEnterBackground:(UIApplication *)application {
    [UIView setAnimationsEnabled:NO];
     [tabBarController.view endEditing:YES];
}

如果这起作用,您需要在applicationWillEnterForeground中重新启用它们

您是否尝试在applicationWillResignActive中执行这些操作?是的,同样的问题。我已经在ApplicationIdentinterBackground中设置了endEditing,ApplicationIdentinterSignative和ApplicationWill依次终止。我也尝试过在它后面加上[NSThread sleepForTimeInterval:0.5]——这会导致应用程序再次出现时出现黑屏,而不是半成品动画。还不知道哪一个更好。。。