选中时我有一个UITextView
可编辑的键盘。问题是当文本太大时,他会躲在键盘后面。我怎么解决这个问题?
问问题
830 次
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
编辑 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 回答