-(BOOL)textFieldShouldReturn:(UITextField*)textField { // When the user pressesreturn, take focus away from the text field so that the keyboard isdismissed. NSTimeIntervalanimationDuration = 0.30f; [UIViewbeginAnimations:@"ResizeForKeyboard"context:nil]; [UIViewsetAnimationDuration:animationDuration]; CGRect rect =CGRectMake(0.0f, 0.0f, self.view.frame.size.width,self.view.frame.size.height); self.view.frame =rect; [UIViewcommitAnimations]; [textFieldresignFirstResponder]; return YES; }
在UITextFieldDelegate委托中,修改view的frame-(BOOL)textFieldShouldReturn:(UITextField*)textField { // When the user pressesreturn, take focus away from the text field so that the keyboard