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);

            

        }

        

       

    }

  • 相关阅读:
    第七章 过滤器 Filter(二)
    第七章 过滤器基础 Filter
    学了近一个月的java web 感想
    js写的一个简单的手风琴菜单
    第六章 对象作用域与servlet事件监听器
    第五章 Web应用程序状态管理
    第四章 使用Servlet处理HTTP请求
    第三章 使用Servlet处理HTTP响应
    第二章 Servlet基础
    myeclipse解决Fail to create the java Virtual Machine
  • 原文地址:https://www.cnblogs.com/gzz2016/p/5283339.html
Copyright © 2011-2022 走看看