当显示键盘时,我有一个需要调整位置的UI.
以下用于检测键盘何时显示:
[[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(keyboarDWillShow:) name:UIKeyboarDWillShowNotification object:nil];
注意:我尝试过UIKeyboarDWillShowNotification和UIKeyboardDIDShowNotification
- (voID)keyboarDWillShow:(NSNotification *)n { if (isKeyboardShowing) return;NSDictionary* userInfo = [n userInfo];// get the size of the keyboardCGSize keyboardSize = [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;// Animate keyboard shift[self.vIEw layoutIfNeeded];[UIVIEw animateWithDuration:0.2f animations:^{ // some animation here} completion:^(BOol finished) { if (finished) isKeyboardShowing = YES;}];
对于自定义键盘,键盘大小返回{320,0}.由于键盘现在可以具有不同的高度,因此在呈现键盘时我无法使用静态值来更改UI.
这是ios8的问题吗?有没有其他方法动态获取键盘高度?
编辑:这是userInfo Dict:
{name = UIKeyboardDIDShowNotification; userInfo = { UIKeyboardAnimationCurveUserInfoKey = 7; UIKeyboardAnimationDurationUserInfoKey = "0.25"; UIKeyboardBoundsUserInfoKey = "NSRect: {{0,0},{320,0}}"; UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160,568}"; UIKeyboardCenterEndUserInfoKey = "NSPoint: {160,568}"; UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0,568},0}}"; UIKeyboardFrameEndUserInfoKey = "NSRect: {{0,0}}";}}
提前致谢.
解决方法 使用CGSize keyboardSize = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
获得键盘的实际大小
总结以上是内存溢出为你收集整理的iOS8 UIKeyboardWillShowNotification第三方键盘高度全部内容,希望文章能够帮你解决iOS8 UIKeyboardWillShowNotification第三方键盘高度所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)