实时获取键盘高度 CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
注意:要想实时获取键盘的高度,比如当前如果是中文那么就会增高的。那么需要使用 UIKeyboardFrameEndUserInfoKey 而不是 UIKeyboardFrameBeginUserInfoKey,后者将获取到的是上次的高度,而前者是键盘动画完成后的最终高度。
|
The following code (sorry for the length) displays an odd behavior under iOS 4.3 (maybe others version too). In this example, there are three see below:
and
Note that this is the expected behavior.
The unexpected behavior is if you start editing a text field the size of the first keyboard is reported (expected). When you touch the second text field (without touching return), the size of first keyboard is reported (unexpected) instead of the size of the second. When you touch the third text field (without touching return), the size of the second keyboard size is reported (unexpected) instead of the size of the third. For the second to nth times, it seems like it is reporting the previous keyboard's size not the one that will be displayed.
Before I send in a bug report, I just want to make sure that I have not over looked anything. FYI I stubbled upon this while trying to do the right thing (using How to make a UITextField move up when keyboard is present iOS Library: Text, Web, and Editing Programming Guide for iOS --> Managing the Keyboard iOS Library: Scroll View Programming Guide for iOS --> Creating and Configuring Scroll Views BugVC.h
BugVC.m
|
||
|
add comment |
|
As reported in this question, the |
实时获取键盘高度 CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;的更多相关文章
- ios5 中文键盘高度变高覆盖现有ui问题的解决方案(获取键盘高度的方法)(转载)
背景: ios5之前,iphone上的键盘的高度是固定为216.0px高的,中文汉字的选择框是悬浮的,所以不少应用都将此高度来标注键盘的高度(包括米聊也是这么做的). 可是在ios5中,键盘布局变了, ...
- js如何获取键盘高度
在移动端或混合app开发中,js如何获取键盘高度,直接贴上代码吧 input是一个html input 标签 var timer = { id:null, run:function (callback ...
- react native 之 获取键盘高度
多说不如多撸: /** * Created by shaotingzhou on 2017/2/23. *//** * Sample React Native App * https://github ...
- iOS、Xcode监测键盘的显示和隐藏变化,并获得键盘高度,改变tableView的frame和偏移
<pre name="code" class="objc"><pre name="code" class="ob ...
- iOS键盘中英文切换键盘高度获取通知方法
iOS键盘中英文切换键盘高度获取通知方法, 有需要的朋友可以参考下. 注册通知 - (void)viewWillAppear:(BOOL)animated { [super viewWillAppea ...
- iOS之 利用通知(NSNotificationCenter)获取键盘的高度,以及显示和隐藏键盘时修改界面的注意事项
我们在开发中会遇到这样的情况:调用键盘时需要界面有一个调整,避免键盘遮掩输入框. 但实现时你会发现,在不同的手机上键盘的高度是不同的.这里列举一下: //获取键盘的高度 /* iphone 6: 中文 ...
- iOS键盘高度的获取
代码如下: - (void)viewDidLoad { [super viewDidLoad]; //增加监听,当键盘出现或改变时收出消息 [[NSNotificationCenter default ...
- Swift3.0 键盘高度监听获取
方法:通过通知监听键盘的动态 1.键盘的动态有四种: public static let UIKeyboardWillShow: NSNotification.Name public static l ...
- iOS键盘高度自适应(中英文输入)
一:添加通知监测键盘高度变化 [self keyBoardAutoSize]; 二:动态改变高度 #pragma mark keyboard height auto /* NSNotification ...
随机推荐
- NOIP 2017 图书管理员
题目描述 图书馆中每本书都有一个图书编码,可以用于快速检索图书,这个图书编码是一个 正整数. 每位借书的读者手中有一个需求码,这个需求码也是一个正整数.如果一本书的图 书编码恰好以读者的需求码结尾,那 ...
- 无法连接Elasticsearch解决方案
前言 最近还是在弄ELK,并且在测试Logstash从kafka消费日志(最后输出到Elasticsearch). 测试完毕后,在kibana中,并没有发现Elasticsearch中的数据. 后来装 ...
- 如何用纯 CSS 创作一个永动的牛顿摆
效果预览 在线演示 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/qKmGaJ 可交互视频教 ...
- perl学习一:探索Perl世界
1.perl4种变量 scalar: $ 纯变量,标量array: @hash: %file: 大写 2.变量组成 1.命名规则 大小写敏感 . 字母数字下划线...2.无关键字,$+其他,但不可以与 ...
- cs229_part4
又到了一节很重要的课,因为这个学习理论是从统计角度为机器学习算法提供了一个理论基础. 学习理论 问题背景 先回顾一下我们第一节课提到的机器学习的组成: 第一节课只是简单的提了一下,现在我们要真正来分析 ...
- mac下secureCRT 客户端 $redis-cli回车后没有反应的解决办法
启动redis server后,SecureCRT进入redis-cli,输入不断在后面追加IP:Port显示设置当前的Session Options-->Terminal-->Emula ...
- Java-在JVM关闭前调用的函数
参考:http://qtlkw.iteye.com/blog/1018872 package com.tj; import java.text.SimpleDateFormat; import jav ...
- python类可以截获Python运算符
类可以截获Python运算符 现在,让我们来看类和模块的第三个主要差别: 运算符重载.简而言之,运算符重载就是让用类写成的对象,可截获并响应用在内置类型上的运算:加法.切片.打印和点号运算等.这只是自 ...
- 【Luogu】P1462通往奥格瑞玛的道路(二分答案+SPFA)
题目链接 导致我WA十几遍的原因居然是最大值不够大……以后再也不相信memset(dis,127/3,sizeof(dis))了. 此题先将花费排序,然后二分最大花费,spfa判断解是否可行.spfa ...
- BZOJ 3270 博物馆 ——概率DP 高斯消元
用$F(i,j)$表示A在i,B在j的概率. 然后很容易列出转移方程. 然后可以高斯消元了! 被一个问题困扰了很久,为什么起始点的概率要加上1. (因为其他博客上都是直接写成-1,雾) 考虑初始状态是 ...