【发布时间】:2016-07-14 21:26:04
【问题描述】:
我有这段代码可以在键盘打开时缩小和移动我的控件:
-(void)keyboardWillShow:(NSNotification *)notification {
NSValue *value = [notification.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];
NSTimeInterval interval = 0;
[value getValue:&interval];
CGSize keyboardSize = [[notification.userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
[UIView animateWithDuration:interval animations:^{
self.composeBarBottomConstraint.constant = (-1) * keyboardSize.height;
[self.view layoutIfNeeded];
}];
}
这适用于普通键盘,但是当我点击表情符号键盘按钮时,UI 控件的位置不在它应该在的位置(向上偏移)并且跳跃而不是动画 - 让我想到我从 @987654322 检索到的值@ 表情符号键盘有问题。
有什么想法吗?
【问题讨论】:
-
如果您尝试使用
UIKeyboardFrameEndUserInfoKey而不是UIKeyboardFrameBeginUserInfoKey会发生什么? -
@Azat 它确实有效!你能解释一下原因吗?
-
我添加了这个作为答案
标签: ios objective-c autolayout uikeyboard