2016-02-22 listening keyboard hidden bar

Source: Internet
Author: User

-(BOOL) prefersstatusbarhidden{

return YES;

}//Hide Bar

2: Make the keyboard disappear

[_lastfield Resignfirstresponder];

[Self.view endediting:yes];//gzz0223

//

gzz0223 Keyboard Disappears

Nsarray *subviews = [Self.view subviews];

For (ID objinput in subviews) {

if ([Objinput Iskindofclass:[uitextfield class]]) {

Uitextfield *thetextfield = objinput;

if ([Objinput Isfirstresponder]) {

[Thetextfield Resignfirstresponder];

//            }

//        }

//    }

[[[uiapplication sharedapplication] keywindow] endediting:YES];

// monitor keyboard appears

[[nsnotificationcenter defaultcenter] addobserver:self selector:@ Selector(keyboardwillshow:) name:uikeyboardwillshownotification object:nil];

// monitor keyboard disappears

[[nsnotificationcenter defaultcenter] addobserver:self selector:@ Selector(keyboardwillhide:) name:uikeyboardwillhidenotification object:nil];

}

keyboard appears , move Chatview up

-(void) Keyboardwillshow: (nsnotification*) noti{

// Get the height of the keyboard

cgsize size = [Noti. UserInfo[uikeyboardframeenduserinfokey] cgrectvalue]. Size;

// screen width high

cgsize winsize = self. View. Frame. Size;

size of the //tableview

_tableview. Frame = cgrectmake(0, 0, winsize. Width, winsize. Height - - -size. Height);

location of the //chatview

_chatview. Frame = cgrectmake(0, winsize. Height - - -size. Height, winsize. Width, (+ );

}

keyboard disappears, restores Chatview to its original position

-(void) Keyboardwillhide: (nsnotification*) noti{

// screen width high

cgsize winsize = self. View. Frame. Size;

size Recovery of //tableview

_tableview. Frame = cgrectmake(0, 0, winsize. Width, winsize. Height - +);

location Recovery of //chatview

_chatview. Frame = cgrectmake(0, winsize. Height - winsize. Width, (+ );

}

2016-02-22 listening keyboard hidden bar

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.