作者:崔显莉京_716 | 来源:互联网 | 2023-09-11 04:09
Iamdevelopingachatapplicationwhichhastextviewandotherbuttonsplacedonaview.Ihavean
I am developing a chat application which has textview and other buttons placed on a view. I have an issue with iOS8 keyboard when predictive is set on. When predictive is off it is working fine but it is set on my view in which textview and other buttons are placed is displaces.
我正在开发一个聊天应用程序,它在视图上放置了textview和其他按钮。设置预测时,iOS8键盘出现问题。当预测功能关闭时,它工作正常但是在我的视图中设置了textview和其他按钮的位置。
I added NSNotification for KeyboardWillShow and KeyboardWillHide in viewDidLoad.
我在viewDidLoad中为KeyboardWillShow和KeyboardWillHide添加了NSNotification。
viewDummy is a view where textview and other buttons are added
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;
}];
}
![](https://www.#.com/imgs/4/2/2/1/88/52e66d7cd6f27a14e3672302c178ad89.jpe)
![enter image description here](https://www.#.com/imgs/0/1/0/6/21/1ce7e59272154d05015e3e12e569a0fc.jpe)
1 个解决方案