• iOS获取键盘的高度


    - (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

    {

        

    }

  • 相关阅读:
    CSS命名规范
    dev 从表处理
    core直接获取报异常数据
    SQL根据指定节点ID获取所有父级节点和子级节点(转载)
    bootstrap的tree使用
    ef报错(因为相同类型的其他实体已具有相同的主键值)
    yii初体验(2)创建方法
    yii初体验(1)composer安装+环境检测
    layui数据表格中图片无法自适应问题
    tp5查询数据库排除某字段
  • 原文地址:https://www.cnblogs.com/zxykit/p/5275569.html
Copyright © 2020-2023  润新知