zoukankan      html  css  js  c++  java
  • iOS获取键盘的高度(简洁有效)

    iOS获取键盘的高度

    (2013-03-06 17:45:31)
    1. - (void)viewDidLoad

      {

          [super viewDidLoad];

          

          //增加监听,当键盘出现或改变时收出消息

          [[NSNotificationCenter defaultCenter] addObserver:self

                                                  selector:@selector(keyboardWillShow:)

                                                      name:UIKeyboardWillShowNotification

                                                    object:nil];

          

          //增加监听,当键退出时收出消息

          [[NSNotificationCenter defaultCenter] addObserver:self

                                                  selector:@selector(keyboardWillHide:)

                                                      name:UIKeyboardWillHideNotification

                                                    object:nil];

          

          

      }

       

      //当键盘出现或改变时调用

      - (void)keyboardWillShow:(NSNotification *)aNotification

      {

          //获取键盘的高度

          NSDictionary *userInfo = [aNotification userInfo];

          NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];

          CGRect keyboardRect = [aValue CGRectValue];

          int height = keyboardRect.size.height;

      }

       

      //当键退出时调用

      - (void)keyboardWillHide:(NSNotification *)aNotification

      {

          

      }

       
  • 相关阅读:
    推荐:Markdown编辑软件 --- 小书匠
    GoldenDict词典配置
    ivew admin
    FineUI学习网址
    博客主题说明网址
    Xshell,Xftp免费版下载方法
    linux 常用命令及操作
    Oracle数据库随机取某条记录的一个字段值
    service和ingress
    centos7离线安装docker (二进制)
  • 原文地址:https://www.cnblogs.com/transcendent/p/4816847.html
Copyright © 2011-2022 走看看