zoukankan      html  css  js  c++  java
  • 键盘弹出消失监听

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

     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification  object:nil];

    [[NSNotificationCenter defaultCenter] removeObserver:self];

    #pragma mark - keyboard

    - (void)keyboardWillShow:(NSNotification *)notification

    {

        NSDictionary *info = notification.userInfo;

        NSValue *kbFrame = [info objectForKey:UIKeyboardFrameEndUserInfoKey];

        CGRect keyboardFrame = [kbFrame CGRectValue];

        CGFloat height = keyboardFrame.size.height;

        _keyH = height;

        

    //    [self.tableV setContentOffset:CGPointMake(self.tableV.contentOffset.x, self.tableV.contentOffset.y + _keyH) animated:YES];

        [self.inputView mas_remakeConstraints:^(MASConstraintMaker *make) {

            make.bottom.equalTo(self.moveView.mas_bottom).with.offset(-_keyH);

            make.left.equalTo(self.moveView.mas_left);

            make.right.equalTo(self.moveView.mas_right);

            make.height.mas_equalTo(ALL_HEIGHT(358/2));

        }];

        

    }

     

    - (void)keyboardWillHide:(NSNotification *)notification

    {

        NSDictionary *info = notification.userInfo;

        NSValue *kbFrame = [info objectForKey:UIKeyboardFrameEndUserInfoKey];

        CGRect keyboardFrame = [kbFrame CGRectValue];

        CGFloat height = keyboardFrame.size.height;

        _keyH = height;

        

        //    [UIView animateWithDuration:0.25 animations:^{

        //        self.tableV.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 64);

        ////        self.messageView.frame = CGRectMake(0, SCREEN_HEIGHT + 50, SCREEN_WIDTH,50);

        //    }];

        [self.inputView mas_remakeConstraints:^(MASConstraintMaker *make) {

            make.bottom.equalTo(self.moveView.mas_bottom);

            make.left.equalTo(self.moveView.mas_left);

            make.right.equalTo(self.moveView.mas_right);

            make.height.mas_equalTo(ALL_HEIGHT(358/2));

        }];

        

    }

  • 相关阅读:
    java中的数组
    java中的break continue
    java 自加和短路问题 几个例子
    循环语句
    K-近邻算法小结
    数据结构与算法学习笔记 (三) 排序 搜索
    数据结构与算法学习笔记 (二) 栈 链表 队列 树 堆 图 并查集
    Spark数据分析技术学习笔记(一)——基础概念、RDD使用
    Python数据分析学习笔记
    Python机器学习(Sebastian著 ) 学习笔记——第六章模型评估与参数调优实战(Windows Spyder Python 3.6)
  • 原文地址:https://www.cnblogs.com/shifu/p/5604315.html
Copyright © 2011-2022 走看看