ios处理键盘的大小

  1. iOS的键盘有几个通知

    UIKeyboardWillShowNotification
    UIKeyboardDidShowNotification
    UIKeyboardWillHideNotification
    UIKeyboardDidHideNotification
    
  2. 每一个通知的具体内容是什么呢

    UIKeyboardAnimationCurveUserInfoKey = 7;
    UIKeyboardAnimationDurationUserInfoKey = "0.25";
    UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {375, 258}}";
    UIKeyboardCenterBeginUserInfoKey = "NSPoint: {187.5, 796}";
    UIKeyboardCenterEndUserInfoKey = "NSPoint: {187.5, 538}";
    UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 667}, {375, 258}}";
    UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 409}, {375, 258}}";
    UIKeyboardIsLocalUserInfoKey = 1;
    
  3. 键盘大小的转换
    通知里的大小是屏幕坐标系中的大小和位置,没有考虑旋转。因此需要一次转化。

        let rect = self.view.convertRect(keyboardrect!, fromView: nil)
    
  4. 为啥不能假设键盘有一个固定的大小

    • 不同输入法的键盘大小可能不同 iOS9 的中文输入法比英文的大那么一点点
    • 不同版本的键盘大小也不同
    • 屏幕旋转时,屏幕的大小也不同

转载于:https://www.cnblogs.com/huahuahu/p/ios-chu-li-jian-pan-de-da-xiao.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值