几个页面跳转以及传值(通知传值)
来源:互联网 发布:ubuntu tty 编辑:程序博客网 时间:2024/05/01 00:23
A→B→C→D→A
其中A不是根目录,但是在D上还要跳转回去,并且不用alloc,这时我们可以用如下方法
[self.navigationController popToViewController: [self.navigationController.viewControllers objectAtIndex: ([self.navigationController.viewControllers count] -4)] animated:YES];
并且D要传值给A,这时通知就很好用了
通知传值(一个发送者,一堆接收者,不需要代理协议,直接通过系统的通知中心工作notificationCenter)
在传值页面
首先弄个系统通知中心
NSNotificationCenter * center = [NSNotificationCenter defaultCenter];
NSNotification * notify = [NSNotification notificationWithName:@"regisonName" object:[NSString stringWithFormat:@"%@",[self.dataArray[indexPath.row] objectForKey:@"name"]]];
//第一个参数是通知的名字,就是标示,名一个名字,以备你用这个名字去找对象 第二个参数就是你要传的值,接收要接收的值,这个值必须是对象
[center postNotification:notify];
在接收页面
//NSNotificationCenter * center = [NSNotificationCenter defaultCenter];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(setRegionTitle:)
name:@"regisonName"
object:nil];
//第一个参数:将要干活的对象 第二个参数(方法名,将要干的活) 第三个参数(干活的名字,要与发送者一致) 第四个参数(系统的,暂时不用管)
- (void)setRegionTitle:(NSNotification *)notify{
NSString * object = [notify object];
[_regionButton setTitle:object forState:UIControlStateNormal];
[_regionButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
}
- 几个页面跳转以及传值(通知传值)
- 通知跳转传值
- android页面的跳转以及传值
- 通知跳转传值-姬云鹏
- 通知跳转传值-姬云鹏
- 微信小程序页面跳转传值以及获取值方法
- 页面跳转传值
- js跳转页面并传值以及localStorage的用法
- IOS 页面之间的跳转以及传值
- Controller向前端传值以及跳转页面
- 页面跳转传值,两个页面跳转cookie传值。
- 页面不跳转传值
- JqueryMobile页面跳转传值
- 浏览器页面传值跳转
- storyboard 页面传值跳转
- Andriod 页面跳转传值
- ios页面跳转传值
- 页面跳转与传值
- 产品经理之复审原型
- gradle学习(19)-log系统
- 对pair的sort
- automake 安装及使用
- Select和epoll的区别
- 几个页面跳转以及传值(通知传值)
- 【C++ Primer】【学习笔记】【第十章】关联容器之:map类型
- 数据结构课程设计03
- LeetCode--Sort Colors
- [汉诺塔][第二阶段-汉诺塔入门][HDOJ-2077]汉诺塔IV
- visualgo动态学习数据结构
- 比特币网络的弱点(三)
- java.lang.ClassNotFoundException: org.slf4j.LoggerFactory异常处理
- LeetCode172——Factorial Trailing Zeroes