【发布时间】:2015-03-13 22:17:00
【问题描述】:
直截了当,当我使用 Xcode 6 构建项目时,当键盘即将显示时,屏幕上的组件会正确向上滚动。
但是,当我使用 Xcode 5 构建时,所有组件都会离开屏幕(也就是它们移动得太高了)。我搜索了,但我找不到问题。
此问题仅在 iOS 8 横向模式下出现。在 iOS 7 上一切正常。有谁知道问题是什么?由于某些原因,必须使用 Xcode 5 进行构建。 谢谢!
视图创建时间
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardShown:) name:UIKeyboardWillShowNotification object:nil];
事件处理程序
- (void)keyboardShown:(NSNotification *)notification{
CGSize kbSize = [[notification.userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
float kbHeight = UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation) ? kbSize.height : kbSize.width;
if( [[UIDevice currentDevice].systemVersion doubleValue] >= 8.0) kbHeight = kbSize.height;
_origScrollIndicatorInsets = _legsTableView.scrollIndicatorInsets;
_origContentInset = _legsTableView.contentInset;
UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbHeight, 0.0);
_legsTableView.contentInset = contentInsets;
_legsTableView.scrollIndicatorInsets = contentInsets;
if (_activeTextField) {
CGRect fieldRect = [_legsTableView convertRect:_activeTextField.bounds fromView:_activeTextField];
[_legsTableView scrollRectToVisible:fieldRect animated:YES];
}
}
【问题讨论】:
标签: xcode ios7 scroll ios8 keyboard