使用notification广播实现视图跳转传递数据
来源:互联网 发布:移动互联网数据报告 编辑:程序博客网 时间:2024/04/30 08:35
第一个viewController:
- - (IBAction)pressed:(id)sender {
- // [self performSegueWithIdentifier:@"second" sender:self];
- NSLog(@"send message:%@",firstField.text);
- //页面跳转传值方法二:利用notification
- NSDictionary *dicts = [NSDictionary dictionaryWithObjectsAndKeys:@"one1",@"one",@"two2",@"two",@"three3",@"three", nil];
- //注册(第一步)
- NSNotification *notification =[NSNotification notificationWithName:@"mynotification" object:firstField.text];
- //发送(第二步)
- [[NSNotificationCenter defaultCenter] postNotification:notification];
- //注册+发送也可以一行完成(等效于以上两行)
- [[NSNotificationCenter defaultCenter] postNotificationName:@"mynotification2" object:dicts];//发送一个字典过去
- }
第二个viewController:
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- //接受端:接受(第一步)
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationHandler:) name:@"mynotification" object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationHandler2:) name:@"mynotification2" object:nil];
- }
- //自定义接收信息和处理的方法(第二步)
- -(void) notificationHandler:(NSNotification *) notification{
- secondField.text = [notification object];//收到消息后在UItextField中显示出来
- }
0 0
- 使用notification广播实现视图跳转传递数据
- 使用单例模式封装Intent(实现跳转与携带数据跳转,顺带发送广播)
- Android 使用Intent实现Activity跳转和数据传递
- 使用storyboard实现页面跳转,简单的数据传递
- 使用storyboard实现页面跳转,简单的数据传递
- 使用storyboard实现页面跳转,简单的数据传递
- 使用storyboard实现页面跳转,简单的数据传递
- 使用storyboard实现页面跳转,简单的数据传递
- 使用storyboard实现页面跳转,简单的数据传递
- 使用storyboard实现页面跳转,简单的数据传递
- 使用storyboard实现页面跳转,简单的数据传递
- 使用storyboard实现页面跳转,简单的数据传递
- 使用Intent实现活动间的跳转和数据传递
- Android 使用广播(BroadcastReceiver)传递数据
- Android页面跳转以及数据传递实现
- (4.4.1)使用storyboard实现页面跳转,简单的数据传递
- 【iOS界面处理】使用storyboard实现页面跳转,简单的数据传递
- 【iOS界面处理】使用storyboard实现页面跳转,简单的数据传递
- opecvdll 的测试 代码
- spring 错误
- Android 设计模式之模板模式
- 雷德算法 (快速傅里叶变换中用到的倒位序算法)
- 数据库ORA-01196(ORA-10458/ORA-01110)错误解决方法
- 使用notification广播实现视图跳转传递数据
- LeetCode Add Two Numbers
- Java初学习-泛型初学习
- C/C++学习笔记32:字符串操作与字符子串问题
- Windows进程间各种通信方式浅谈
- Groovy入门教程
- java使用Apache POI操作excel文件
- 错误:expected unqualified-id before ‘template’
- jsp中禁止页面缓存