ios 通知
来源:互联网 发布:天敏网络机顶盒打不开 编辑:程序博客网 时间:2024/05/22 06:07
//添加字典,将label的值通过key值设置传递
NSDictionary*dict =[[NSDictionary alloc]initWithObjectsAndKeys:self.textFieldOne.text,@"textOne",self.textFieldTwo.text,@"textTwo",nil];
//创建通知
NSNotification *notification =[NSNotification notificationWithName:@"tongzhi" object:nil userInfo:dict];
//通过通知中心发送通知
[[NSNotificationCenter defaultCenter] postNotification:notification];
[self.navigationControllerpopViewControllerAnimated:YES];
在发送通知后,在所要接收的控制器中注册通知监听者,将通知发送的信息接收
- (void)viewDidLoad {
[super viewDidLoad];
//注册通知
[[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(tongzhi:)name:@"tongzhi"object:nil];
}
- (void)tongzhi:(NSNotification *)text{
NSLog(@"%@",text.userInfo[@"textOne"]);
NSLog(@"-----接收到通知------");
}
移除通知:removeObserver:和removeObserver:name:object:
其中,removeObserver:是删除通知中心保存的调度表一个观察者的所有入口,而removeObserver:name:object:是删除匹配了通知中心保存的调度表中观察者的一个入口。
这个比较简单,直接调用该方法就行。例如:
[[NSNotificationCenter defaultCenter] removeObserver:observer name:nil object:self];
注意参数notificationObserver为要删除的观察者,一定不能置为nil。
- ios 通知
- IOS 通知
- iOS通知
- iOS 通知
- IOS通知
- IOS 通知
- iOS-通知
- iOS通知
- ios 通知
- iOS 【通知】
- iOS通知
- IOS 通知
- ios 通知
- iOS 通知
- iOS - 通知
- ios 通知
- iOS 本地通知 远程通知
- iOS本地通知 远程通知
- linux下源码安装nginx
- 投稿时Cover Letter的重要性
- 指针的指针...
- 数据字典项 设计实现方案
- 前端面试题目搜集——理论知识
- ios 通知
- 重拾编程之路--leetcode(java)--删除(覆盖)指定数组元素,输出新长度
- ListView 如何判断ListView是否可以滑动(即ListView的Item总数是否超过可视区域)
- C Primer Plus学习笔记之第一,二章——预备知识
- 华为机试——整数与IP地址间的转换
- 三种UITableViewCell刷新的方法
- leetcode:292. Nim Game
- 字符串转枚举类型
- swift 2.0 字符串操作...