// When there is input. The height of the keyboard changes dynamically. The height of Chinese input is different from that of English input. Therefore, you must change the position of the input box. # pragma mark-keyboardhight-(void) viewwillappear :( bool) animated {[self defined];}-(void) viewwilldisappear :( bool) animated {[[nsnotifcenter center defacenter center] removeobserver: Self];}-(void) registerforkeyboardconfigurations {// use nsicationicationcenter to publish the current [[nsicationicationcenter defacenter] addobserver: Self selector: @ selector (keyboardwasshown :) name: uikey Boarddidshownotification object: Nil]; // when using nsicationicationcenter center to hide [nsnotificationcenter defacenter center] addobserver: Self selector: @ selector (keyboardwillbehidden :) name: jsonobject: Nil];} // calculate the height of the keyboard when it appears. Used to display location-(void) keyboardwasshown :( nsnotification *) anotification {nsdictionary * info = [anotification userinfo] in the input box; // kbsize is the size (with width and height) cgsize kbsize = [[info objectforkey: uikeyboardframeenduserinfokey] cgrectvalue]. size; // obtain the nslog (@ "hight_hitht: % F", kbsize. height); If (kbsize. height = 216) {keyboardhight = 0;} else {keyboardhight = 36; // 252-216 two different heights of the system keyboard} // input box position animation loading [self be Gainmoveupanimation: keyboardhight];} // when the keyboard is hidden-(void) keyboardwillbehidden :( nsnotification *) anotification {// do something} // (textview) before the keyboard starts inputting. -(Void) textviewdidbeginediting :( uitextview *) textview {nslog (@ "gegin Animation"); sendmsgtextview = textview; resultcommunitytableview. frame = cgrectmake (0, 36,320,150); // animated loading [self ainainmoveupanimation: 0.0];} // disable the keyboard (textview) for changing the row. Hide the keyboard-(bool) textview :( uitextview *) textview shouldchangetextinrange :( nsange) range replacementtext :( nsstring *) text {resultcommunitytableview. frame = cgrectmake (0, 36,320,376); If ([text isequaltostring: @ "\ n"]) {[textview resignfirstresponder]; return no;} return yes ;} // call the animation when the input ends (press the button. Background. Move all input boxes)-(void) textviewdidendediting :( uitextview *) textview {nslog (@ "tabtabtab"); [self endeditanimation]; // release [nsicationicationcenter defacenter] removeobserver: self name: uikeyboardwillshownotification object: Nil]; [[nsicationcenter center defacenter center] removeobserver: Self name: icationobject: Nil];} // judge the current input method-(void) textviewdidchangeselection :( uitextview *) textview {nslog (@ "Wewe: % @", [[uitextinputmode currentinputmode] primarylanguage]); /* If ([[uitextinputmode currentinputmode] primarylanguage] = @ "En-us") {nslog (@ "En-us ");} else {nslog (@ "ZH-Hans ");}*/}
Dynamically Retrieve keyboard height