0

when user tap on uitextfiel, I just animate view to up so, keyboard not hid that field. it work properly but in between that if I rotate device it not work properly.

my view code is as below

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return ((interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown));
}
-(void)textFieldShouldReturn:(id) sender
{
[sender resignFirstResponder];
}
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
[self animateTextField:textField up:YES];
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
[self animateTextField:textField up:NO];
}
-(void)animateTextField:(UITextField*)textField up:(BOOL)up
{
const int movementDistance = -130;
const float movementDuration = 0.3f;

int movement = (up ? movementDistance : -movementDistance);

[UIView beginAnimations: @"animateTextField" context: nil];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration: movementDuration];
self.view.frame = CGRectOffset(self.view.frame, 0, movement);
[UIView commitAnimations];
}

when I tap on textfield, check below

enter image description here

enter image description here

In this keyboard up position I just rotate my device, check below

enter image description here

when I tap on return on keyboard, check below

enter image description here

you can see, the issue

Thanks

4

1 回答 1

0
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);




[textfield resign first responder];
}

无论您使用什么功能,只需添加

[textfield resign first responder];
于 2013-04-05T11:49:12.183 回答