ios-Keyboard Monitor Yykeyboardmanager

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.