• 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

      {

          

      }

       
  • 相关阅读:
    解析数据库xml格式字段
    Spring切面表达式,hibernate,struts
    常见枚举
    经典冒泡排序,九九乘法表,三角形
    拦截器后台安全验证
    Oracle 将表中多条数据同一字段拼成一列显示
    idea 11 控制台日志乱码
    BigDecimal 分转元,元转分
    currtDownLatch可能会出现的三个问题
    CountDownLatch用法
  • 原文地址:https://www.cnblogs.com/transcendent/p/4816847.html
Copyright © 2020-2023  润新知