在我的iPad应用程序中,我有几个textView
和textField's
。当我点击textField
时,键盘覆盖了textField
。所以我正在实现下面的代码来移动textview。但轮到portraitUpsideDown
它不能正常工作。它向相反的方向滑动屏幕。那么我该如何解决这个问题?键盘隐藏在ipad中的不同方向的textfield
-(void) animateTextField: (UITextView *) textField up: (BOOL) up
{
int txtPosition = (textField.frame.origin.y - 540);
const int movementDistance = (txtPosition < 0 ? 0 : txtPosition); // 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];
}
-(void)textViewDidBeginEditing:(UITextView *)textField
{
[self animateTextField: textField up: YES];
}
-(void)textViewDidEndEditing:(UITextView *)textField
{
[self animateTextField: textField up: NO];
}
-(BOOL)textFieldShouldReturn:(UITextView *)theTextField
{
[theTextField resignFirstResponder];
return YES;
}
oopss解释了这个....刚才我检查了你的问题again..Its为iPad ...所有的方位都接受......对不起,给了你错误的信息... – 2012-01-09 05:53:27
@ DineshRaja.MaG那么我该如何解决这个问题? – crazy2431 2012-01-09 06:00:05