通知NSNotificationCenter
注意:接受通知要写在 viewDidLoad 方法里面
取得系统全局的唯一广播站
NSNotificationCenter *notification = [NSNotificationCenter defaultCenter];
设置广播的名字和 参数等。。。
[notification postNotificationName:@” ChangeTheme” object:self userInfo:自己要传的的参数];
给系统ChangeTheme频段发送一个广播
频段的名字是ChangeTheme 频段的名字不能重复
注册成为ChangeTheme这个频段的听众
NSNotificationCenter *notification = [NSNoyification defaultCenter];
Notification addobserver:self selector:@selector(recvBcast:) name:@“ChangeTheme”
接受广播 ChangeTheme
一旦有广播了就让系统自动调用 self里面的recvBCast: 函数
-(void) recvBCast:(NSNotification *)notification
{
recvBCast:不是我们调用的 是iOS系统调用
NSString *name = [notify name];
Name其实就是ChangeTheme
Id obj = [notify object];
Obj就是所在的viewcontroller
NSdictionary *dict = [notify userInfo];
Dict 就是传过来的值
}
通知NSNotificationCenter的更多相关文章
- iOS之 利用通知(NSNotificationCenter)获取键盘的高度,以及显示和隐藏键盘时修改界面的注意事项
我们在开发中会遇到这样的情况:调用键盘时需要界面有一个调整,避免键盘遮掩输入框. 但实现时你会发现,在不同的手机上键盘的高度是不同的.这里列举一下: //获取键盘的高度 /* iphone 6: 中文 ...
- OC学习篇之---通知(NSNotificationCenter)
在前一篇文章中我们介绍了OC中很常用的两个技术:KVC和KVO: http://blog.csdn.net/jiangwei0910410003/article/details/41912937,今天 ...
- 通知 - NSNotificationCenter
1.每一个应用程序都有一个通知中心(NSNotificationCenter)实例,专门负责协助不同对象之间的消息通信: 2.任何一个对象都可以向通知中心发布通知(NSNotification), 描 ...
- iOS通知NSNotificationCenter
NSNotificationCenter消息通信 作用:NSNotificationCenter是专门供程序中不同类间的消息通信而设置的. 注册通知:即要在什么地方接受消息 [[NSNotificat ...
- ios注册通知NSNotificationCenter(一)
作用:NSNotificationCenter是专门供程序中不同类间的消息通信而设置的. 注册通知:即要在什么地方接受消息 [[NSNotificationCenter defaultCenter] ...
- 通知(NSNotificationCenter)
// 监听加载更多的通知 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loadMoreDeals ...
- NSNotificationCenter通知中心
概述 NSNotificationCenter通知中心,通常用于一对一或者一对多的消息传递,即当一个地方改变时,要求改变其他的一些地方,例如当网络请求回来了新的数据,需要刷新本地信息和本地内存里面的界 ...
- iOS中通知中心NSNotificationCenter应用总结
通知中心(NSNotificationCenter)实际是在程序内部提供了一种广播机制.把接收到的消息,根据内部的消息转发表,将消息转发给需要的对象.这句话其实已经很明显的告诉我们要如何使用通知了.第 ...
- Swift - 使用NSNotificationCenter发送通知,接收通知
转载自:http://www.mamicode.com/info-detail-1069228.html 标签: 1,通知(NSNotification)介绍 这里所说的通知不是指发给用户看的通知消息 ...
随机推荐
- 【转】Git代码提交最佳实践
GIT Commit Good Practice The following document is based on experience doing code development, bug ...
- Android 自学之列表选择框Spinner
列表选择框(Spinner)与Swing编程里面的Spinner不同,这里的Spinner其实就是一个列表选项框. Spinner是ViewGroup的间接子类,因此他也可作为容器使用. Spinne ...
- 关于Collections中的sort()方法总结
用Java集合中的Collections.sort方法对list排序的两种方法 本文部分引用自:http://my.oschina.net/leoson/blog/131904 用Collection ...
- 项目中 mysql中的内容关于上架时间和下架时间
隐藏左边导航 在mysql中,是存放的10位的时间截,在后台添加时,时间的格式是:'Y-m-d H:i',没有秒的 字段 字段名称 字段类型 是否为空 默认值 备注 publish_up int(11 ...
- ADO.NET通用数据库访问类
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- dede版权信息修改
login:dede-templets-login.htm 系统主页:dede-templets-index2.htm 主体内容在index_body.htm文件 干掉: $(function() ...
- ASP清除字串中的重复字符
<% Function Test(str) dim intLen,i,strTemp,aryTest intLen = Len(str) strTemp = "" aryTe ...
- ASP 生成带日期的随机数
<% Function getRnd() '**************************************** '返回值:如getRnd(),即输出2008082415534646 ...
- Android——将图片加入到系统相册里面
Adnroid中保存图片的方法可能有如下两种: 第一种是自己写方法,如下代码: public static File saveImage(Bitmap bmp) { File appDir = new ...
- MongoDB启动配置等
目录: 一.mongoDB 启动配置 二.导出,导入,运行时备份 三.Fsync锁,数据修复 四.用户管理,安全认证 一.启动项 mongod --help C:\Windows\system32&g ...