zoukankan      html  css  js  c++  java
  • 2016-03-16 键盘的弹出与收起

    1:通知

     [[NSNotificationCenter defaultCenter] addObserver:self

                                                 selector:@selector(keyboardWasShown:)

                                                     name:UIKeyboardDidShowNotification object:nil];

        [[NSNotificationCenter defaultCenter] addObserver:self

                                                 selector:@selector(keyboardWillBeHidden:)

                                                     name:UIKeyboardWillHideNotification object:nil];

    2:方法:

    //键盘显示,调整tableview的高度

    - (void)keyboardWasShown:(NSNotification*)aNotification

    {

       

        //获取通知传递过来的信息

        NSDictionary* info = [aNotification userInfo];

        //获取键盘的size

        CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;

        //得到UIEdgeInsets

        UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height, 0.0);

        

       

        

        //设置tableviewUIEdgeInsets

        self.tableView.contentInset = contentInsets;

        self.tableView.scrollIndicatorInsets = contentInsets;

        

        if (isYesName) {

            

            textFieldView.frame = CGRectMake(0, SCREEN_HEIGHT-kbSize.height-60-64, SCREEN_WIDTH, 60);

            

        }

        

    }

     

    //键盘收起,恢复tableviewUIEdgeInsets

    - (void)keyboardWillBeHidden:(NSNotification*)aNotification

    {

        

        UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0,0.0 , 0.0);

        self.tableView.contentInset = contentInsets;

        self.tableView.scrollIndicatorInsets = contentInsets;

        

        

        if (isYesName) {

            

            textFieldView.frame = CGRectMake(0, SCREEN_HEIGHT-64, SCREEN_WIDTH, 60);

            

        }

        

       

    }

  • 相关阅读:
    unity打包iOS上线归纳
    unity update优化
    3dmax 法线重置
    unity2017分离动作
    unity5 manifest
    Unity5 AssetBundle资源管理架构设计
    ue4 tags 与 cast
    3dmax tcb控制器
    ue4 创建简易动画
    即时战略游戏中实用的寻路算法都有哪些,比较如何?
  • 原文地址:https://www.cnblogs.com/gzz2016/p/5283339.html
Copyright © 2011-2022 走看看