我正在开发一个聊天应用程序,它在视图上放置了textview和其他按钮。设置预测时,iOS8键盘出现问题。 当预测功能关闭时,它工作正常但是在我的视图中设置了textview和其他按钮的位置。
我在viewDidLoad中为KeyboardWillShow和KeyboardWillHide添加了NSNotification。
viewDummy是添加textview和其他按钮的视图
- (void)keyboardWillShow:(NSNotification *)notification {
NSDictionary* info = [notification userInfo];
CGRect kKeyBoardFrame = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
[UIView animateWithDuration:0.2f animations:^{
CGRect frame = viewDummy.frame;
frame.origin.y -= kbSize.height;
viewDummy.frame = frame;
frame = bubbleTable.frame;
frame.size.height -= kbSize.height;
bubbleTable.frame = frame;
}];
}
-(void) keyboardWillHide:(NSNotification *)note{
NSDictionary* info = [note userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
[UIView animateWithDuration:0.2f animations:^{
CGRect frame = viewDummy.frame;
frame.origin.y += kbSize.height;
viewDummy.frame = frame;
frame = bubbleTable.frame;
frame.size.height += kbSize.height;
bubbleTable.frame = frame;
}];
}
答案 0 :(得分:0)