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获取键盘的相关信息(高度,类型等)。

  • 相关阅读:
    USACO Sabotage
    USACO Telephone Lines
    NOIP 2012 借教室
    洛谷 P1902 刺杀大使
    VIJOS-P1450 包裹快递
    JDOJ 1770 埃及分数
    USACO Monthly Expense
    7.modifier插件的自定义和使用
    6.function自定义插件的方法和使用
    5.Smart使用内置函数或者自定义函数
  • 原文地址:https://www.cnblogs.com/nanoCramer/p/3178623.html
Copyright © 2011-2022 走看看