私はUITextView(目的:コメント)を画面の下部に固定しています。ユーザーがコメントを追加したい場合は、キーボードが表示され、コメントの上にコメントがシフトします。キーボードを隠すためのキャンセルボタンもありますが、キーボードは隠されていません。キーボードがiosに隠されていない
//Set up NSNotification for Keyboard
-(void) viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillToggle:)
name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillToggle:)
name:UIKeyboardWillHideNotification object:nil];
}
//Code to shift comment view up with keyboard
- (void) keyboardWillToggle:(NSNotification *)aNotification
{
CGRect frame = [self.navigationController.toolbar frame];
CGRect keyboard = [[aNotification.userInfo valueForKey:@"UIKeyboardFrameEndUserInfoKey"] CGRectValue];
frame.origin.y = keyboard.origin.y - frame.size.height;
[UIView animateWithDuration:[[aNotification.userInfo valueForKey:@"UIKeyboardAnimationDurationUserInfoKey"] floatValue] animations:^
{
[self.navigationController.toolbar setFrame:frame];
}];
}
//Hide keyboard
-(void)cancelComment:(UIBarButtonItem*)sender{
NSLog(@"cancelComment called");
[self.view endEditing:YES];
}
私はこれがうまくいくはずですか? "と呼ばれるcancelCommentは、" コンソールに記録されているが、キーボードが
で[yourtextfield resignfirstresponder]これを追加考える
を試すことができます。 in cancelComment –
それは、サブビューとしてテキストフィールドを持っているビューコントローラにありますか? – Wain
ああそうだよ>。
abcf