textfile开始编辑事件为“Editing did Begin” ,结束事件为“Did end on exit”
方法一
- (IBAction)exitKeyboard:(id)sender { [sender resignFirstResponder]; [UIView beginAnimations:@"ResizeForKeyboard" context:nil]; [UIView setAnimationDuration:0.30f]; CGRect frame = self.view.frame; frame.origin.y +=216; frame.size. height -=216; self.view.frame = frame; [UIView commitAnimations]; } - (IBAction)editBegin:(id)sender { [UIView beginAnimations:@"ResizeForKeyboard" context:nil]; [UIView setAnimationDuration:0.30f]; CGRect frame = self.view.frame; frame.origin.y -=216; frame.size.height +=216; self.view.frame = frame; [UIView commitAnimations]; }
-(IBAction) slideFrameUp { [self slideFrame:YES]; } -(IBAction) slideFrameDown { [self slideFrame:NO]; } -(void) slideFrame:(BOOL) up { const int movementDistance = 60; // tweak as needed const float movementDuration = 0.3f; // tweak as needed int movement = (up ? -movementDistance : movementDistance); [UIView beginAnimations: @"anim" context: nil]; [UIView setAnimationBeginsFromCurrentState: YES]; [UIView setAnimationDuration: movementDuration]; self.view.frame = CGRectOffset(self.view.frame, 0, movement); [UIView commitAnimations]; }
[tfPwd resignFirstResponder]; [tfAccount resignFirstResponder];