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];
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/3098182.html