ios NavigationViewController跳转以及返回传值
(一)使用NavigationViewController进行页面跳转时,应该使用pushViewController方法来跳转至下一页面。这种话。下一页面相同在NavigationViewController容器中。
1、跳转到下一页面:
PowerViewController *power = [[PowerViewController
alloc] init];
//所要跳转页面PowerViewController中有个属性dictionary1是个NSMutableDictionary类型的容器[power.dictionary1
setObject:[self.outTxtPass text] forKey:ALONE_SITEPRIZE_PWD];//使用pushViewController跳转到下一页面[self.navigationController
pushViewController:power animated:YES];2、从当前页面返回到上一页面并传值过去:
//此页面已经存在于self.navigationController.viewControllers中,而且是当前页面的前一页面
PowerViewController
*power = [self.navigationController.viewControllers objectAtIndex:self.navigationController.viewControllers.count-2];//初始化其属性power.dictionary
= nil;//传递參数过去power.dictionary
= [NSMutableDictionary dictionaryWithDictionary:self.dictionary1];//使用popToViewController返回并传值到上一页面[self.navigationController
popToViewController:power
animated:YES];返回到上一页后,上一页面显示后要接收參数,并刷新。
注意此时应该在viewDidAppear中进行推断并接收传递的值:
-(void)viewDidAppear:(BOOL)animated{ //推断并接收返回的參数}//返回到上一界面-(IBAction)backOff:(id)sender{ [self.navigationController
popViewControllerAnimated:true];}(二)关于ios中 viewcontroller的跳转问题。当中有一种方式是採用navigationController pushViewController 的方法,比方我从主页面跳转到了一级页面,又从一级页面跳转到了二级页面。然后从二级页面跳转到了三级页面,依次类推。假设一级一级的返回我知道是没有问题的。调用navigationController popViewControllerAnimated即可了。
可是某些情况下我可能想要立即回到主页面,而不是一级一级的返回(假设有非常多层会非常累的),那该怎么办呢?
1.返回根页面vc用
[self.navigationController
popToRootViewController]
2.返回根页面vc用
:
[self.navigationController
popToViewController:[self.navigationController.viewControllers objectAtIndex:2] animated:YES];
或(通过class定位)
for
(UIViewController *controller in self.navigationController.viewControllers) { if
([controller isKindOfClass:[TargetController class]])
{ [self.navigationController
popToViewController:controller animated:YES]; }}ios NavigationViewController跳转以及返回传值的更多相关文章
- ios--NavigationViewController跳转、返回传值
使用NavigationViewController进行页面跳转时,应该使用pushViewController方法来跳转至下一页面,这样的话,下一页面同样在NavigationViewContr ...
- iOS Scheme 跳转主流实现方案
iOS Scheme跳转主流实现方案主要是路由跳转,目前iOS常用路由框架是JLRouter.HHRouter.MGJRouter. 但是这些路由库都各有不足,首先是JLRouter,用不到的功能繁多 ...
- iOS界面跳转的一些优化方案
原文地址: http://blog.startry.com/2016/02/14/Think-Of-UIViewController-Switch/ iOS界面跳转的一些优化方案 App应用程序开发, ...
- Android——关于Activity跳转的返回(无返回值和有返回值)——有返回值
说明: 跳转页面,并将第一页的Edittext输入的数据通过按钮Button传到第二页用Edittext显示,点击第二页的 返回按钮Button返回第一页(改变第二页的Edittext的内容会传至第一 ...
- iOS页面跳转及数据传递
转: http://blog.csdn.net/wang9834664/article/details/8025571 iOS页面跳转: 第一种 [self.navigationController ...
- iOS 10 跳转系统设置
苦心人天不负, 为了项目终于把 iOS 10 跳转系统设置的方法给搞定了, 很欣慰. http://www.cnblogs.com/lurenq/p/6189580.html iOS 10 跳转系统设 ...
- ios页面跳转
reference:http://blog.csdn.net/engandend/article/details/11706323 目前,就我所学到的内容,页面跳转有三种方法 一.直接推到下一个页面 ...
- react-router(v4) 路由跳转后返回页面顶部问题
遇到的问题 由A页面跳转到B页面,B页面停留在A页面的位置,没有返回到顶部. 问题分析 首先分析下出现此问题的原因: 在项目中使用的是 hashHistory,它是建立在 history 之上的,当路 ...
- 移动端开发在iOS系统中 new Date() 返回 NaN 的问题
问题: 通过 new Date() 函数将后台返回的时间('2021-11-25')获取时间戳.在 chrome 浏览器的手机模拟器中没有出现问题,但在 iPhone 真机测试的时候,显示的结果不符合 ...
随机推荐
- UBI介绍
转:http://blog.csdn.net/kickxxx/article/details/6707589 目录 Table of contents Big red note User-space ...
- md5是哈希算法的改进加强,因为不同原始值可能hash结果一样,但md5则改善了用于验证消息完整性,不同md5值原始值也必将不一样
md5是哈希算法的改进加强,因为不同原始值可能hash结果一样,但md5则改善了用于验证消息完整性,不同md5值原始值也必将不一样
- flask的session解读及flask_login登录过程研究
#!/usr/bin/env python # -*- coding: utf-8 -*- from itsdangerous import URLSafeTimedSerializer from f ...
- flask的session研究和flask-login的session研究
1.httpie的安装:https://github.com/jakubroztocil/httpie#macos 2.http://python.jobbole.com/87450/ 3.http: ...
- Linux用户配置sudo权限(visudo)
sudo的工作过程如下: 1,当用户执行sudo时,系统会主动寻找/etc/sudoers文件,判断该用户是否有执行sudo的权限 2,确认用户具有可执行sudo的权限后,让用户输入用户自己的密码确认 ...
- 走进C++程序世界-----operator new delete 重载
在C++ 的世界里,new 和delete 是keyword.而在C的世界里相相应的malloc和free是函数,关键C++的new和delete分析,详见前面的章节.这里就不在过多的介绍了.链接. ...
- 【Hadoop】Hadoop MR 自定义分组 Partition机制
1.概念 2.Hadoop默认分组机制--所有的Key分到一个组,一个Reduce任务处理 3.代码示例 FlowBean package com.ares.hadoop.mr.flowgroup; ...
- 关于ng-router嵌套使用和总结
那是某个下午的review代码的过程.js中有一段html,像是这样. var html = '<div>...此处还有很多html代码....</div>' 我的同事想我提出 ...
- 倍福TwinCAT(贝福Beckhoff)基础教程1.2 TwinCAT安装配置
由于TC2和TC3都有可能用到,个人推荐都安装,但是注意必须是先安装的TwinCAT2,然后安装TwinCAT3,如果反了可能两个都没法用(打开TcSwitchRuntime提示Both TwinCA ...
- Bounded Context
From http://martinfowler.com/bliki/BoundedContext.html Bounded Context is a central pattern in Domai ...