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;

            

        }];

     

  • 相关阅读:
    mysql类似oracle rownum写法
    mysql派生查询必须有别名问题记录
    MySQL逻辑架构简介
    JSON转成List结构数据
    MySQL锁表查询SQL
    Http请求传json数据中文乱码问题
    异步调用导致的不同步问题
    oracle导入Excel表文本数据
    JSP页面的注释细节
    Oracle cursor学习笔记
  • 原文地址:https://www.cnblogs.com/woaixixi/p/4501250.html
Copyright © 2011-2022 走看看