zoukankan      html  css  js  c++  java
  • 键盘之上的工具栏,完美实现,动画无缺陷

    //键盘代理事件
    - (void)keyboardWillHide:(NSNotification *)notification{
        _keyBoardShowIng = NO;
        [UIView animateWithDuration:.25 animations:^{
            downView.top = MainScreenHeight;
            if (_richTextToolBar) {
                dispatch_async(dispatch_get_main_queue(), ^{
                     _richTextToolBar.hidden = YES;
                });
               
            }
        }];
        
    }
    
    - (void)keyboardWillShow:(NSNotification *)notification{
        _keyBoardShowIng = YES;
         NSDictionary *userInfo = [notification userInfo];
         NSValue * endValue   = [notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
         CGFloat height = [endValue CGRectValue].size.height;
         if(height==0) return;
    
        
        NSNumber *duration = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];
        
        NSNumber *curve = [userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey];
        
        // 添加移动动画,使视图跟随键盘移动
        
        [UIView animateWithDuration:duration.doubleValue animations:^{
            
            [UIView setAnimationBeginsFromCurrentState:YES];
            
            [UIView setAnimationCurve:[curve intValue]];
            
            downView.bottom = MainScreenHeight - height;
            
        }];
    }
    
    但是记得下面
    
    -(void)viewDidDisappear:(BOOL)animated
    {
        [super viewDidDisappear:animated];
        
        [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
         [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
    
    }
    
    -(void)viewWillAppear:(BOOL)animated{
        [super viewWillAppear:animated];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
    
    }
    
  • 相关阅读:
    我理解的朴素贝叶斯模型
    P2P贷款全攻略,贷前、贷中、贷后工作事项解析
    Jupyter Notebook 快速入门
    R语言|数据特征分析
    R语言︱处理缺失数据&&异常值检验、离群点分析、异常值处理
    mysql explain执行计划详解
    R语言中的回归诊断-- car包
    一行代码搞定 R 语言模型输出!(使用 stargazer 包)
    基于R语言的时间序列指数模型
    基于R语言的ARIMA模型
  • 原文地址:https://www.cnblogs.com/widgetbox/p/8352552.html
Copyright © 2011-2022 走看看