Kvo to monitor keyboard pop-up and bounce back

Source: Internet
Author: User
Tags notification center

Set up a broadcast in the notification center to listen for pop-up and bounce of the keyboard, and to include actions to trigger events in the listener event.

Object : nil];     object: nil];

Some notifications for listening to the keyboard:

 //  Span style= "color: #008000;" >//  uikeyboardwillchangeframenotification  //  uikeyboarddidchangeframenotification     notifications issued when keyboard is displayed  //  uikeyboardwillshownotification  //  Uik Eyboarddidshownotification  //     Notification issued when the keyboard is hidden  //     Uikeyboardwillhidenotification  //  Uikeyboarddidhidenotification  

The effect I need to implement here (e.g.) is to move the lower toolbar up to the appropriate position when the keyboard pops up, so you need to know the height of the keyboard and the time to pop the animation, and broadcast listening to get the keyboard frame and pop-up animation time:

NSString *duration = Userinfo[uikeyboardanimationdurationuserinfokey];     = [Userinfo[uikeyboardframeenduserinfokey] cgrectvalue];

The animation effect changes the frame of TableView and toolbar so that the keyboard will not be obscured when it pops up:

[UIView animatewithduration:[duration Doublevalue] Delay:0.0Options:uiviewanimationoptioncurvelinear animations:^{_tableview.frame= CGRectMake (0, -, Size.width, Size.Height- --KeyboardFrame.size.height- -); Footview.frame= CGRectMake (0, Size.height-keyboardframe.size.height- -, Size.width, -); } Completion:^(BOOL finished) {Nsindexpath*path = [Nsindexpath indexpathforrow:_dataarray.count-1Insection:0];    [_tableview Scrolltorowatindexpath:path Atscrollposition:uitableviewscrollpositionbottom Animated:YES]; }];

Kvo to monitor keyboard pop-up and bounce back

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.