当predictive设置为on时,ios 8键盘问题
我正在开发一个聊天应用程序,它在视图上有文本视图和其他按钮。当predictive设置为on时,我的iOS8键盘出现问题。 当“预测”处于禁用状态时,它工作正常,但它在“我的视图”上设置,其中放置了textview和其他按钮 我在viewDidLoad中为KeyboardWillShow和KeyboardWillHide添加了NSNotification viewDummy是添加textview和其他按钮的视图当predictive设置为on时,ios 8键盘问题,ios,objective-c,xcode,Ios,Objective C,Xcode,我正在开发一个聊天应用程序,它在视图上有文本视图和其他按钮。当predictive设置为on时,我的iOS8键盘出现问题。 当“预测”处于禁用状态时,它工作正常,但它在“我的视图”上设置,其中放置了textview和其他按钮 我在viewDidLoad中为KeyboardWillShow和KeyboardWillHide添加了NSNotification viewDummy是添加textview和其他按钮的视图 - (void)keyboardWillShow:(NSNotification *
- (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;
}];
}
- 我为解决这个问题所做的是:
- 根据差异手动调整kbSize.height
- 我的身高相差44
- 所以我做的是frame.origin.y+=kbSize.height+44或 frame.origin.y-=kbSize.height+44,我想这可能会对您有所帮助
UIKeyboardWillChangeFrameNotification
和UIKeyboardDidChangeFrameNotification
在打开/关闭预测输入时发布通知。注册这些通知可能会对您有所帮助。