選択するとUITextView
編集可能になり、キーボードが表示されます。問題は、テキストが大きすぎると、キーボードの後ろに隠れてしまうことです。どうすればこの問題を解決できますか?
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
この質問はすでに何度も聞かれています。質問を投稿する前にグーグルをしてください。とにかく...
他の誰かが尋ねたこの質問を参照して、コミュニティwikiになりました。この質問には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 に答える