- (BOOL)textFieldShouldReturn:(UITextField *)textField { // When the user presses return, take focus away from the text field so that the keyboard is dismissed. NSTimeInterval animationDuration = 0.30f; [UIView beginAnimations:@"ResizeForKeyboard" context:nil]; [UIView setAnimationDuration:animationDuration]; CGRect rect = CGRectMake(0.0f, 0.0f, self.view.frame.size.width, self.view.frame.size.height); self.view.frame = rect; [UIView commitAnimations]; [textField resignFirstResponder]; return YES; }