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 真机测试的时候,显示的结果不符合 ...
随机推荐
- C++ development cross platforms
1. target platforms: linux suse, windows server, both use vmware virtual machine on lab server. 2. c ...
- [置顶]
cAdvisor、InfluxDB、Grafana搭建Docker1.12性能监控平台
通过cadvisor+influxdb+grafana三者有机结合,打造跨主机容器监控. 优点 1.跨主机监控,可扩展 2.容器自发现 3.历史数据长期保存 4.自定义配置程度高 缺点 1.不能自动隐 ...
- python测试与调试提示
测试与调试提示 2.1 在交互模式输入一个python语句就会执行一个.在调试程序时,这种模式尤其有用. 2.2 在一个文件调用python解释器后,解释器会在文件中的最后一个语句执行之后推出.然而, ...
- Vue表单和组件
一.表单 v-model 指令在表单控件元素上创建双向数据绑定,v-model 会根据控件类型自动选取正确的方法来更新元素. <input v-model="message" ...
- ES查询tags字段为空或null
现需要查询出tags为 "" 或者为 null 的数据 { "query": { "bool": { "must": { ...
- sass高级语法的补充
1. 继承 2.混入 3.函数 我这篇博客需要点基础才能看懂, 但我这篇博客是对上一篇的 sass高级语法 的补充 从这方面来看也无所谓了
- java-selenium(一)元素定位
在定位单个元素时,selenium-webdriver 提示了如下一些方法对元素进行定位.下面这些定位方式中,优先使用 id.name.classname,对于网上的链接元素,推荐使用linkText ...
- UI自动化测试篇 :ReportNG替代TestNG自带html版测试报告初探
转载http://www.cnblogs.com/chengtch/p/6071322.html “1.1.4版本的ReportNG是最后一个版本,之后不再做维护.作为一个简单的测试报告插件,它是创造 ...
- 字符串截取 及 substr 和 substring 的区别
1..字符串截取 str.substr(0, 1) // 获取字符串第一个字符 str.substr(-1) // 获取字符串最后一个字符 str.charAt(str.length - 1) // ...
- vi 替换操作
举例一: ,$s/// 从第一行到最后一行 147都替换为150 举例二: 例:替换当前文件中所有old为new :%s/old/new/g #%表示替换说有行,g表示替换一行中所有匹配点. 举例三: ...