zoukankan      html  css  js  c++  java
  • 通知中心

    // 发出通知

        [[NSNotificationCenter defaultCenter] postNotificationName:HMTabBarDidSelectNotification object:nil userInfo:@{HMTabBarSelectIndex : @(button.tag)}];

    postNotificationName : 通知名称

    object:设法通知的,可以不写,不告诉别人是谁发出的

    userInfo:将要传出去的参数

    //接受通知

    //监听键盘的通知(只要键盘改变frame的时候就会通知)

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

    //Observer:self 自身

    //selector:监听后调用的方法

    //name:监听通知的名称,

    //object:监听的对象,nil 可以是任何对象

    //移除通知

    -(void)dealloc

    {

        //移除观察者

        [[NSNotificationCenter defaultCenter] removeObserver:self];

    }

  • 相关阅读:
    日志
    JAVA字符串类
    JAVA包
    JAVA面向对象
    JAVA数组
    JAVA循环结构
    JAVA程序调试
    JAVA条件判断
    JAVA算术运算符
    JAVA数据类型
  • 原文地址:https://www.cnblogs.com/yyj900165/p/4864031.html
Copyright © 2011-2022 走看看