【发布时间】:2015-11-13 13:36:32
【问题描述】:
我正在做一个项目,我有一个 UIView,其中包含多个 UI 元素,包括一个 UITextField。一旦UITextField 激活(即becomesFirstResponder),弹出的键盘将覆盖UITextField。包含所有 UI 元素的 UIView 位于 UIScrollView 中。
现在,除了将 contentView 上移到 UIScrollView 的可见区域之外,我需要做的另一件事是确保用户无法滚动键盘下方(和后面)的 contentView,也无法滚动 contentView上方(和导航栏后面)。
我目前的相关代码是:
-(void)keyboardDidShow:(NSNotification *)notification {
CGFloat height = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
self.scrollViewBottomContstraint.constant = height;
[self.view layoutIfNeeded];
}
谁能告诉我如何确保我的 contentView 只能在导航栏和键盘之间的可见区域内最小限度地滚动?
【问题讨论】:
标签: ios uiscrollview autolayout uitextfield