Notifications for IOS listening keyboard

Source: Internet
Author: User

Notification Method:

/** * Call when the keyboard changes frame (position and size)*/- (void)Keyboardwillchangeframe:(Nsnotification *) note{//set the color of the windowSelf.view.window.backgroundColor =Self.tableView.backgroundColor; //0. Time to remove keyboard animationsCGFloat Duration =[Note.userinfo[uikeyboardanimationdurationuserinfokey] doublevalue]; //1. Get the last frame of the keyboardCGRect Keyboardframe =[Note.userinfo[uikeyboardframeenduserinfokey] cgrectvalue]; //2. Calculate the distance that the controller's view needs to be shiftedCGFloat transformy = KEYBOARDFRAME.ORIGIN.Y-Self.view.frame.size.height; //3. Performing animations[UIView animatewithduration:duration animations:^{self.view.transform= Cgaffinetransformmaketranslation (0, Transformy); }];}/*Uikeyboardanimationcurveuserinfokey = 7; The execution rhythm of the animation (speed) Uikeyboardanimationdurationuserinfokey = "0.25"; The time required for keyboard popup \ Hide Animation Uikeyboardboundsuserinfokey = "Nsrect: {{0, 0}, {320, 216}}"; Uikeyboardcenterbeginuserinfokey = "Nspoint: {160, 588}"; Uikeyboardcenterenduserinfokey = "Nspoint: {160, 372}";  uikeyboardframechangedbyuserinteraction = 0; Keyboard Popup Uikeyboardframebeginuserinfokey = "Nsrect: {{0, 480}, {320, 216}}";//keyboard just came out of that moment frame Uikeyboardframeenduserinfokey = "Nsrect: {{0, 264}, {320, 216}}"; frame//keyboard hidden after keyboard display Uikeyboardframebeginuserinfokey = "Nsrect: {{0, 264}, {320, 216}}"; Uikeyboardframeenduserinfokey = "Nsrect: {{0, 480}, {320, 216}}"; */

Invoke Notification:

    // 2. Notification    of keyboard monitoring [[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (keyboardwillchangeframe:  Object: nil];

Move out of monitoring arc

-(void) dealloc{    //[Super Dealloc]; This step is required for non-arc conditions     [[ Nsnotificationcenter defaultcenter]removeobserver:self];}

Notifications for IOS listening keyboard

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.