zoukankan      html  css  js  c++  java
  • 键盘上附加工具栏

    m_listView:textview在tableview上,同时需要修改tableview高度 

    //注册观察者

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

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

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboarWillShow:) name:UIKeyboardWillChangeFrameNotification object:nil];

    //显示附加工具栏

    -(void)keyboarWillShow:(NSNotification*)obj{

    //获取键盘的高度

        NSDictionary *userInfo = [obj userInfo];

        NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];

        CGRect keyboardRect = [aValue CGRectValue];

        int height = keyboardRect.size.height;

    [UIView animateWithDuration:0.2f animations:^(){

    [m_listView setFrame:CGRectMake(0, [Utility getNavBarHight], ScreenWidth, ScreenHeight - [Utility getNavBarHight] - 50 - height)];

    [menuView setFrame:CGRectMake(0, ScreenHeight - 50-height, m_listView.frame.size.width, 50)];

    }];

    [m_listView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:m_listView.curText.tag inSection:0] atScrollPosition:UITableViewScrollPositionNone animated:YES];

    }

    -(void)keyboardWillBeHidden:(NSNotification*)obj{

    [UIView animateWithDuration:0.3f animations:^(){

    [m_listView setFrame:CGRectMake(0, [Utility getNavBarHight], ScreenWidth, ScreenHeight - [Utility getNavBarHight] - 50)];

    [menuView setFrame:CGRectMake(0, m_listView.frame.origin.y+ m_listView.frame.size.height, m_listView.frame.size.width, 50)];

    }];

    }

  • 相关阅读:
    【解题报告】2019正睿Day2
    如何卡SPFA
    【游记】2019国庆清北刷题营
    CF427D Match & Catch
    P2178 [NOI2015] 品酒大会
    Loj#6071. 「2017 山东一轮集训 Day5」字符串
    SP8093 JZPGYZ
    P3346 [ZJOI2015]诸神眷顾的幻想乡
    CF1037H Security
    CF932F Escape Through Leaf
  • 原文地址:https://www.cnblogs.com/ldc529/p/3832260.html
Copyright © 2011-2022 走看看