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;

            

        }];

     

  • 相关阅读:
    latex之插入伪代码 [转]
    BIBTeX制作参考文献 [转]
    latex 页眉设置 [转]
    python : list tuple set dictionary [转]
    ctags使用简介 [转]
    conda在指定目录下创建虚拟环境
    Ubuntu系统安装Anaconda3
    ModuleNotFoundError: No module named 'google' 问题解决方案
    PyCharm无法输入中文
    checkpoint文件
  • 原文地址:https://www.cnblogs.com/woaixixi/p/4501250.html
Copyright © 2011-2022 走看看