在我的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