zoukankan      html  css  js  c++  java
  • 关于IOS获取keyBoard键盘是否弹出

    工程中需要需要实现自定义的弹出提示框,暂时的实现方法是alloc一个view出来,以subView的方式加在底部的webView上面正中间,这样在keyboard弹出时,提示框被遮住,需要修改。

    既然是keyBoard引起的问题,那我们就获取keyBoard弹出的状态,如果是弹出状态,那么调整位置,使提示框能正常显示。

    我们在ViewDidLoad里添加下面俩个方法:

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

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

    addObserver:注册一个观察员name:消息名称

    以上步骤完成后,在键盘弹出时,系统监听到,就会调用:

    - (void)keyboardWillShow:(NSNotification *)notification;

    在键盘隐藏后,会调用:

    - (void)keyboardWillhide:(NSNotification *)notification;

    我们还可以通过notification获取键盘的相关信息(高度,类型等)。

  • 相关阅读:
    java线程
    面向切面编程
    控制反转IOC与依赖注入DI
    phpexecel 导入导出,格式
    PHPExcel设置数据格式的几种方法
    九度oj 题目1416:猴子吃坚果
    九度oj 题目1397:查找数段
    poj 1065 Wooden Sticks
    poj 3181 Dollar Dayz
    poj 1742 Coins
  • 原文地址:https://www.cnblogs.com/nanoCramer/p/3178623.html
Copyright © 2011-2022 走看看