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);

    }

     

  • 相关阅读:
    欧几里得 与 扩展欧几里得
    hdu-1559 最大子矩阵
    hdu-1081 To The Max (最大子矩阵和)
    Oracle处理排序问题
    报表犯的错误
    MySQL中汉字一二三排序问题
    MySQL复习
    帆软查看显示和填报显示
    MySQL某年查询12个月份的数据
    mysql中去日期格式
  • 原文地址:https://www.cnblogs.com/AlienY/p/4539931.html
Copyright © 2011-2022 走看看