zoukankan      html  css  js  c++  java
  • 注册监听键盘事件的通知

    注册监听键盘事件的通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardShow:) name:UIKeyboardDidShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardHide:) name:UIKeyboardDidHideNotification object:nil];

     

     在键盘将要出现和隐藏的回调中

    - (void)keyboardWillShows:(NSNotification *)notif

    {

        CGRect frame = [[notif.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];

     

        CGFloat  offset= -frame.size.height;

     

        [UIView animateWithDuration:0.3 animations:^{

            CGRect  rect  =self.frame;

           

            rect.origin.y=offset;

           

            self.frame=rect;

           

        }];

     

    }

     

     

    - (void)keyboardWillHides:(NSNotification *)notif

    {

     

       

        [UIView animateWithDuration:0.3 animations:^{

            CGRect  rect  =self.frame;

           

            rect.origin.y=0;

           

            self.frame=rect;

            

        }];

     

  • 相关阅读:
    根据指定月份,打印该月份所属的季节
    求出1~100之间,既是3又是7的倍数的自然数出现的次数
    打印所有的水仙花数
    升景坊单间短期出租
    找出1000以内的所有完数
    ssh config host
    shell获取ip
    mongodb sharding 简单部署记录
    tcp转发
    openssl和Java的keytool证书相关的命令总结
  • 原文地址:https://www.cnblogs.com/woaixixi/p/4501250.html
Copyright © 2011-2022 走看看