通知中心
2015-10-09 15:13
501 查看
// 发出通知
[[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];
}
[[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];
}
相关文章推荐
- 多项式插值
- php学习基础篇之mysql DDL DML 2
- sublime3+quick3.5 完整使用教程
- 机器翻译
- 【SQL优化】子查询展开
- git客户端创建本地公钥
- 课下参考七--Linux的安装详解--开场白
- bnuoj 24258 Journey(lca倍增法 弱校联萌十一大决战之背水一战J)
- 自测-2 素数对猜想 (20分)
- a标签的onclick事件与href详解
- HBase集群搭建
- Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:]解决方法
- 断言(Assertion)需要注意的一个地方
- 断言(Assertion)需要注意的一个地方
- 断言(Assertion)需要注意的一个地方
- nagios监控mysql
- 【笔记】最长上升子序列
- 3.Python标准库_路径与文件 (os.path包, glob包)
- linux增加自定义path和manpath
- centos7下安装配置redis3.0.4