UIKeyboardWillShowNotification我有一个和的观察者UIKeyboardWillHideNotification。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
这一切都有效,除了当 viewController 当前不可见时它有效。
我试过比较,self.navigationcontroller.topViewController但是当我有一个模态视图时这不起作用,因为它topViewController是模态视图控制器下面的视图。