UITableView about keyboard blocking input box workaround

Source: Internet
Author: User

aboutkeyboardeventviewcontroller.m//querybussinessinfo////Created by Mac on 16/8/23.//copyright©2016 year CQYTJR . All rights reserved.//#import "AboutKeyBoardEventViewController.h" @interface Aboutkeyboardeventviewcontroller () @    End@implementation aboutkeyboardeventviewcontroller-(void) viewdidload {[Super viewdidload];    Self.tableview = [[UITableView alloc]initwithframe:self.view.bounds];    [Self.view AddSubview:self.tableView]; Listen for keyboard popup events [[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (keyboardwillshow:) Name:    Uikeyboardwillshownotification Object:nil]; Listen for keyboard hidden events [[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (keyboardwillhide:) Name: Uikeyboardwillhidenotification Object:nil];} -(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section{return 0;} -(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{return nil;} #pragma mark-Keyboard is about to eject event handling-(void) Keyboardwillshow: (nsnotification *) notification{//Get keyboard info nsdictionary *keyboardinfo = [Notifica        tion UserInfo];        Get animation time CGFloat duration = [[Keyboardinfo Objectforkey:uikeyboardanimationdurationuserinfokey] floatvalue];    Get the frame information of the keyboard nsvalue *value = [Keyboardinfo Objectforkey:uikeyboardframeenduserinfokey];            Cgsize keyboardsize = [value cgrectvalue].size;        [UIView animatewithduration:duration animations:^{//CGRect frame = _chatbar.frame;        FRAME.ORIGIN.Y = Screenheight-keyboardsize.height-frame.size.height;        _chatbar.frame = frame;        CGRect rect = self.tableView.frame;        Rect.size.height = Keyboardsize.height;            Self.tableView.frame = rect; } Completion:nil];} #pragma mark-The keyboard is about to hide events-(void) Keyboardwillhide: (nsnotification *) notification{//Get keyboard information nsdictionary *keyboardi        NFO = [notification UserInfo]; Get animation time CGFloat duration = [[K]Eyboardinfo Objectforkey:uikeyboardanimationdurationuserinfokey] Floatvalue]; Get the frame information for the keyboard [UIView animatewithduration:duration animations:^{cgrect rect = self.tableView.frame        ;        Rect.size.height = Self.view.bounds.size.height;    Self.tableView.frame = rect; } Completion:nil];}    -(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} /* #pragma mark-navigation//in a storyboard-based application, you'll often want to do a little preparation before Nav igation-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) Sender {//Get the new view controller using [SEG    UE Destinationviewcontroller]. Pass the selected object to the new view Controller.} */@end

UITableView about keyboard blocking input box workaround

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.