IOS8 after the third-party keyboard gets the wrong height

Source: Internet
Author: User

IOS8 after the Apple can install a third-party keyboard,

By breakpoints we will find that after using a third-party keyboard,

The keyboard will pop up method:-(void) Keyboardwillshow: (nsnotification *) notification will execute three times,

The height of the three times is: 0:216:282. We find that what we need is the height of the third time.

We need to register the keyboard to hide and display the notifications:

[[Nsnotificationcenter defaultcenter]addobserver:self selector: @selector (keyboarddidhide:) Name: Uikeyboardwillhidenotification Object:nil];

[[Nsnotificationcenter defaultcenter]addobserver:self selector: @selector (keyboardwillshow:) Name: Uikeyboardwillshownotification Object:nil];

1 #pragmamark– Keyboard Display Events2 3- (void) Keyboardwillshow: (Nsnotification *) Notification {4CGFloat curkeyboardheight = [[[Notification UserInfo] Objectforkey:@"Uikeyboardboundsuserinfokey"] Cgrectvalue].size.height;5CGRect begin = [[[Notification UserInfo] Objectforkey:@"Uikeyboardframebeginuserinfokey"] Cgrectvalue];6CGRect end = [[[Notification UserInfo] Objectforkey:@"Uikeyboardframeenduserinfokey"] Cgrectvalue];7     8     //third-party keyboard callback three issues, listening only to perform the last9     if(begin.size.height>0&& (begin.origin.y-end.origin.y>0)){Ten          OneCGFloat keyboardheight =Curkeyboardheight; A          -NSLog (@"third time:%f", keyboardheight); -[UIView animatewithduration:0.05animations:^{ theSelf.bgView.hidden =NO; -SELF.COMMENTTOOLVIEW.Y = Kscreenheight-keyboardheight- -; -              -         }]; +     } - } +  A #pragmamark– keyboard-Hidden events at  --(void) Keyboarddidhide: (Nsnotification *) notification{ -NSLog (@"Keyboard Hide"); -Self.bgView.hidden =YES; -SELF.COMMENTTOOLVIEW.Y =Kscreenheight; -}

IOS8 after the third-party keyboard gets the wrong height

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.