ANKeyboardObserverManager make your keyboard observe easier and more flexible. I
To install ANKeyboardObserverManager either:
pod 'ANKeyboardObserverManager'
- or copy Source/ANKeyboardObserverManager.h and Source/ANKeyboardObserverManager.m in your project.
Use [ANKeyboardObserverManager sharedManager] directly or alloc/init ANKeyboardObserverManager instance in the class you want to use it.
Then add the observer:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[ANKeyboardObserverManager sharedManager] addKeyboardObserver:self
withkeyboardWillShowBlock:^(CGRect keyboardEndFrame, NSTimeInterval animateDuration, NSDictionary *info) {
your code
}
keyboardWillHideBlock:^(CGRect keyboardEndFrame, NSTimeInterval animateDuration, NSDictionary *info) {
your code
}];
}
When you do not want to observe the keyboard, remove the observer:
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[[ANKeyboardObserverManager sharedManager] removeKeyboardObserver:self];
}