If the keyboard pop-up overwrite the original attempt, this effect is not good, so we will be in the keyboard pop-up, listening to the location of the keyboard to change some of our attempts to position, if TableView list, and so on, recommend a Daniel Ibireme write Yykeyboardmanager, git address: https://github.com/ibireme/YYKeyboardManager; import with cocoapods: Pod ' yykeyboardmanager ', terminal pod Install is ready to use.
Turn on keyboard monitoring
Header file Reference: #import "YYKeyboardManager.h"
[[Yykeyboardmanager Defaultmanager] addobserver:self];
Implementing a Proxy
<YYKeyboardObserver>
Proxy method
- (void) Keyboardchangedwithtransition: (yykeyboardtransition) Transition {[UIView animatewithduration: Transition.animationduration Delay:0Options:transition.animationOption animations:^{ ///Use this method to get the rect of the keyboardCGRect Kbframe =[[Yykeyboardmanager Defaultmanager] ConvertRect:transition.toFrame ToView:self.view]; ///new calculation of the location of the view and assigning valuesCGRect 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
And don't forget to remove the listener at the release point.
-(void) dealloc { [[Yykeyboardmanager Defaultmanager] removeobserver:self];}
Finally attach an original git on the project:
ios-Keyboard Monitor Yykeyboardmanager