Notification Method:
/** * Call when the keyboard changes frame (position and size)*/- (void)Keyboardwillchangeframe:(Nsnotification *) note{//set the color of the windowSelf.view.window.backgroundColor =Self.tableView.backgroundColor; //0. Time to remove keyboard animationsCGFloat Duration =[Note.userinfo[uikeyboardanimationdurationuserinfokey] doublevalue]; //1. Get the last frame of the keyboardCGRect Keyboardframe =[Note.userinfo[uikeyboardframeenduserinfokey] cgrectvalue]; //2. Calculate the distance that the controller's view needs to be shiftedCGFloat transformy = KEYBOARDFRAME.ORIGIN.Y-Self.view.frame.size.height; //3. Performing animations[UIView animatewithduration:duration animations:^{self.view.transform= Cgaffinetransformmaketranslation (0, Transformy); }];}/*Uikeyboardanimationcurveuserinfokey = 7; The execution rhythm of the animation (speed) Uikeyboardanimationdurationuserinfokey = "0.25"; The time required for keyboard popup \ Hide Animation Uikeyboardboundsuserinfokey = "Nsrect: {{0, 0}, {320, 216}}"; Uikeyboardcenterbeginuserinfokey = "Nspoint: {160, 588}"; Uikeyboardcenterenduserinfokey = "Nspoint: {160, 372}"; uikeyboardframechangedbyuserinteraction = 0; Keyboard Popup Uikeyboardframebeginuserinfokey = "Nsrect: {{0, 480}, {320, 216}}";//keyboard just came out of that moment frame Uikeyboardframeenduserinfokey = "Nsrect: {{0, 264}, {320, 216}}"; frame//keyboard hidden after keyboard display Uikeyboardframebeginuserinfokey = "Nsrect: {{0, 264}, {320, 216}}"; Uikeyboardframeenduserinfokey = "Nsrect: {{0, 480}, {320, 216}}"; */
Invoke Notification:
// 2. Notification of keyboard monitoring [[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (keyboardwillchangeframe: Object: nil];
Move out of monitoring arc
-(void) dealloc{ //[Super Dealloc]; This step is required for non-arc conditions [[ Nsnotificationcenter defaultcenter]removeobserver:self];}
Notifications for IOS listening keyboard