IOS-keyboard listening for YYKeyboardManager,

Source: Internet
Author: User

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:

 

Related Article

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.