zoukankan      html  css  js  c++  java
  • 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

    {

        

    }

  • 相关阅读:
    单例模式(上)单例常见的实现方式
    Netty(六)揭开 BootStrap 的神秘面纱
    Netty(五)Netty 高性能之道
    Netty(四)基于Netty 的简易版RPC
    Netty(三)基于Bio和Netty 的简易版Tomcat
    Netty(二)Netty 与 NIO 之前世今生
    java学习笔记
    Java使用笔记之对象比较
    React学习之受控和非受控组件
    SpringBoot学习之常用注解
  • 原文地址:https://www.cnblogs.com/zxykit/p/5275569.html
Copyright © 2011-2022 走看看