IOS-keyboard listening for YYKeyboardManager,
If the keyboard pop-up overwrites the original attempt, this effect is not good, so we need to listen to the keyboard position during the keyboard pop-up to change some of our attempt positions, such as the tableView list; here, we recommend a YYKeyboardManager written by Daniel ibireme. The Git address is https://github.com/ibireme/yykeyboardmanager#use cocoapodsto import to 'yykeyboardmanager' in the pod install mode.
Enable keyboard listening
Header file reference: # import "YYKeyboardManager. h"
[[YYKeyboardManager defaultManager] addObserver:self];
Implement proxy
<YYKeyboardObserver>
Proxy Method
-(Void) keyboardChangedWithTransition :( YYKeyboardTransition) transition {[UIView animateWithDuration: transition. animationDuration delay: 0 options: transition. animationOption animations: ^ {// use this method to obtain the rect CGRect kbFrame of the keyboard = [[YYKeyboardManager defaultManager] convertRect: transition. toFrame toView: self. view]; // calculate the position of the view and assign the value CGRect textframe = _ textField. frame; textframe. size. width = kbFrame. size. width; textframe. origin. y = kbFrame. origin. y-textframe. size. height; _ textField. frame = textframe;} completion: ^ (BOOL finished) {}];}
Remove listener
Don't forget to remove the listener from the release.
- (void)dealloc { [[YYKeyboardManager defaultManager] removeObserver:self];}
Finally, a previous Git project is attached: