0

选中时我有一个UITextView可编辑的键盘。问题是当文本太大时,他会躲在键盘后面。我怎么解决这个问题?

4

4 回答 4

2

通过此代码向上移动您的视图

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
  //change origin y 
[UIView beginAnimations:nil context:self.view];
            [UIView setAnimationDuration:0.25];
            [self.view setFrame:CGRectMake(0,-150,320,436)];
            [UIView commitAnimations];

}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
   //reset origin y 
[UIView beginAnimations:nil context:self.view];
            [UIView setAnimationDuration:0.25];
            [self.view setFrame:CGRectMake(0,0,320,436)];
            [UIView commitAnimations];

}

根据您的要求设置 x 和 y 值。

于 2012-12-29T13:01:52.600 回答
0

这个问题已经被问过很多次了。请在发布问题之前进行一些谷歌搜索。无论如何...

看到其他人提出的这个问题并已成为社区维基。这个问题已经发布了 31 个答案。

另外,您可以参考本教程

于 2012-12-29T12:57:17.083 回答
0

编辑 UITextField 时更改基本视图大小,减小基本视图原点 y 以编辑文本字段

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
  //change origin y 
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
   //reset origin y 
}
于 2012-12-29T12:57:27.780 回答
0

使用UITextfield.

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
            [UIView beginAnimations:nil context:self.view];
            [UIView setAnimationDuration:duration];
            //change origin y 
            [self.view setFrame:CGRectMake(X,newY,width,height)];
            [UIView commitAnimations];

}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
            [UIView beginAnimations:nil context:self.view];
            [UIView setAnimationDuration:duration];
            //reset origin y 
            [self.view setFrame:CGRectMake(X,Y,width,height)];
            [UIView commitAnimations];
}

不要忘记在“.h”文件和适当的文本文件中设置 UITextFieldDelegate textfiled.delegate = self

于 2012-12-29T13:39:31.867 回答