您的位置:首页 > 其它

通知中心

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

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: