1
キーボードを使用しているときにUIView
全体を動かしているアプリケーションがあります。重要なものを隠さないためにUITextField
を使用しています。UIView
私の問題は、私がそこに持っているUITableView
は他のすべてのビューと同じように動作しないということです。 UITableView
全体を移動するのではなく、その上端のみを移動し、UITableView
のサイズを変更します。これは目的の効果ではありません。
私の問題をよりよくここで説明されていますhttp://www.youtube.com/watch?v=AVJVMiBULEQ
は、これは私がアニメーションのために使っているコードです:
-(void)setViewMovedUp:(BOOL)movedUp
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5]; // if you want to slide up the view
[UIView setAnimationBeginsFromCurrentState:YES];
CGRect rect = self.view.frame;
if (movedUp) {
// 1. move the view's origin up so that the text field that will be hidden come above the keyboard
// 2. increase the size of the view so that the area behind the keyboard is covered up.
rect.origin.y -= 140;
rect.size.height += 140;
} else {
// revert back to the normal state.
rect.origin.y += 140;
rect.size.height -= 140;
}
self.view.frame = rect;
[UIView commitAnimations];
}
フム、私はいつも(下に移動)self.transfom = CGAffineTransformMakeTranslation(0、-140)を形質転換し、self.transform = CGAffineTransformIdentity設定することによってこれを行います。あなたはこれを試して、あなたが同じ結果を得るかどうかを見てみることができますか? –
ありがとうございます。これはうまくいきましたが、アニメーションなしで即座に動きます。これにアニメーションを追加する方法はありますか? – Dimme
Interface Builderで自動サイズ設定オプションを変更して解決しました。 =)サイズ変更に固執していました。 – Dimme