【发布时间】:2014-11-15 08:19:45
【问题描述】:
我正在开发一个聊天应用程序,其中包含 UITableView 和 UIView,其中包含 UITextField 和 UIButton。当键盘出现时,我正在使用以下代码将UIView 向上移动。
(void)keyboardWillShow:(NSNotification *)notification
{
NSDictionary* info = [notification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
[UIView animateWithDuration:0.2f animations:^{
CGRect frame = self.inputView.frame;
UIInterfaceOrientation orientation = self.interfaceOrientation;
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
frame.origin.y -= kbSize.width;
else
frame.origin.y -= kbSize.height;
self.inputView.frame = frame;
;
}];
}
此代码在 iOS 7 之前运行良好,但在 iOS 8 中 UIView 未显示在键盘上方。
谁能建议可能是什么问题,或者 iOS 8 中是否有任何变化?
【问题讨论】:
标签: uitableview uiview keyboard uitextfield ios8