zoukankan      html  css  js  c++  java
  • iOS——UIKeyboardWillShowNotification 监听键盘高度变化

    - (void)viewDidLoad {

        [super viewDidLoad];

        UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(100, 100, 100, 50)];

        textField.backgroundColor = [UIColor blueColor];

        [self.view addSubview:textField];

    //出现键盘

        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];

     //键盘隐藏

     [[NSNotificationCenter defaultCenter] addObserver:self 

                                               selector:@selector(keyboardWillHidden:) 

                                                   name:UIKeyboardWillHideNotification 

                                                 object:self.view.window];

        };

     

    -(void)keyboardWillShow:(NSNotification*)notification{

        NSDictionary*info=[notification userInfo];

        CGSize kbSize=[[info objectForKey:UIKeyboardFrameEndUserInfoKey]CGRectValue].size;

        NSLog(@"keyboard changed, keyboard width = %f, height = %f",

              kbSize.width,kbSize.height);

        //在这里调整UI位置

    }

      //键盘将要消失

    -(void)keyboardWillHidden:(NSNotification*)notification

    {

     

     NSDictionary*info=[notification userInfo];

        CGSize kbSize=[[info objectForKey:UIKeyboardFrameEndUserInfoKey]CGRectValue].size;

        NSLog(@"keyboard changed, keyboard width = %f, height = %f",

              kbSize.width,kbSize.height);

    }

     

  • 相关阅读:
    dremio 学习一 简单了解
    dremio 集群简单部署
    idea 无法添加maven项目问题
    maven几个加速地址配置
    dremio mongodb objectid 转换问题
    cube.js 集成dremio
    dremio 集群部署模式
    timescaledb 2.0 ga了
    dremio 数据湖平台
    dremio 中文查询问题解决
  • 原文地址:https://www.cnblogs.com/AlienY/p/4539931.html
Copyright © 2011-2022 走看看