UITextFieldの下限を指定します。keyboardWillShowでキーボードの高さを検出したときに、UITextFieldの下限の制約をKeyboardHeightに増やします。
次のコードをViewWillAppearに入れてください。
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
そしてViewWillDisappearにコードの下に置きます。
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIKeyboardWillShowNotification
object:nil];
方法
- (void)keyboardWillShow:(NSNotification *)notification
{
// Get the size of the keyboard.
CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
int keyboardHeight = MIN(keyboardSize.height,keyboardSize.width);
textBottom.constant = 0.0f;
for (UIView *vw in commentView.subviews) {
if ([vw isKindOfClass:[UITextField class]]) {
txtComment = (UITextField *)vw;
textBottom.constant = keyboardHeight;
}
}
}
あなたがやりたいことができます。テキストフィールドを移動し、テキストフィールドを含む全体のビューを移動するか、scrollViewを使用します。 'UIScrollView'を使いたくない場合は、ビューまたはテキストフィールドを含むビューを移動してください。あなたが何を求めているのかは分かりません。 – Ryan