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

      {

          

      }

       
  • 相关阅读:
    C语言博客作业03--函数
    Java 图书馆系统
    DS博客作业05--查找
    DS博客作业04--图
    DS博客作业03--树
    C博客作业05--2019-指针
    C语言博客作业04--数组
    C语言博客作业03--函数
    面向对象设计大作业-图书馆查书、借书、还书
    5-互评-OO之接口-DAO模式代码阅读及应用
  • 原文地址:https://www.cnblogs.com/transcendent/p/4816847.html
Copyright © 2011-2022 走看看