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

    {

        

    }

  • 相关阅读:
    Object类的方法简记
    run()和start()调用问题简记
    面向对象设计
    关于JVM的简记
    操作运算符的简记
    jdbc简记
    synchronized的简记
    垃圾回收的一些简记
    java.io.IOException: Stream closed
    Java-文件名、目录名或卷标语法不正确
  • 原文地址:https://www.cnblogs.com/zxykit/p/5275569.html
Copyright © 2011-2022 走看看