NotificationCenter的基本使用
来源:互联网 发布:clean my mac好用吗 编辑:程序博客网 时间:2024/05/24 04:41
NotificationCenter的基本使用:</span>
init方法中:</span>
NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(HelloWorld::call2),"abc",nullptr); //添加观察对象 auto b1 = MenuItemImage::create("CloseNormal.png","CloseNormal.png",CC_CALLBACK_0(HelloWorld::call, this)); //按钮 auto menu = Menu::create(b1, nullptr);this->addChild(menu);
对应的方法:</span>
void HelloWorld::call(){log("call()");NotificationCenter::getInstance()->postNotification("abc", this);}void HelloWorld::call2(Ref* obj){log("call2()");auto s = Sprite::create("CloseNormal.png");s->setPosition(Vec2(100,100));this->addChild(s);}
</pre><pre name="code" class="cpp">最后:
HelloWorld::~HelloWorld(){<span style="white-space:pre"></span>NotificationCenter::getInstance()->removeObserver(this,"abc"); //取消监听 <span style="white-space:pre"></span>//NotificationCenter::getInstance()->removeAllObservers(this);}
0 0
- NotificationCenter的基本使用
- Swift-通知中心(NotificationCenter)的使用
- IOS学习笔记之十四:NotificationCenter的使用以及注意事项
- NotificationCenter
- NotificationCenter
- NotificationCenter
- Cocos2dx NotificationCenter(广播或通告)的使用方法
- cocos2dx EventListenerCustom 和NotificationCenter的优缺点
- Cocos2d-x中,使用NotificationCenter在Layer之间传输数据
- unity3d消息机制研究之二--------javascript 的 NotificationCenter
- 简述NotificationCenter、KVC、KVO、Delegate?它们之间的区别!!!
- 对象间的通信之delegate、notificationCenter与block
- 【Unity3D技巧】在Unity中使用事件/委托机制(event/delegate)进行GameObject之间的通信 (二) : 引入中间层NotificationCenter
- Unity3D NotificationCenter
- NotificationCenter(简介)
- NotificationCenter(实战)
- 简述NotificationCenter,KVC,KVO,delegate,并说明他们之间的区别
- iOS分享 - 对象间的通信之delegate、notificationCenter与block
- 查看修改Linux时区和时间
- JS高级应用积累
- informatica
- 在C语言中会遇到volatile关键字
- 一些可用的Google Ip
- NotificationCenter的基本使用
- 跨站实现HTTP会话劫持
- mysql id按指定的格式自增
- 指针数组和数组指针
- 同步/异步,阻塞/非阻塞
- Android Selector 与 Shape 基本用法
- 第9周项目6穷举法解决组合问题之警察抓小偷
- ARM linux kernel启动流程 head.S(一)
- Cocos2d-X3.0 刨根问底(三)----- Director类源码分析