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 真机测试的时候,显示的结果不符合 ...
随机推荐
- Java Web实现跨域
import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import ja ...
- 如何快速搜索SQL数据库数据和对象
原文 如何快速搜索SQL数据库数据和对象 Frequently, developers and DBAs need to search databases for objects or data. I ...
- java程序监控tomcat中部署的项目的状态以及控制某些项目的启动停止
原文:http://blog.csdn.net/liuyuqin1991/article/details/49280777 步骤如下: ①:首先授权用户使获得这些权限 You can find the ...
- .NET Core简介
内容主要来源 https://docs.asp.net/en/latest/conceptual-overview/dotnetcore.html 什么是.NET Core .NET Core 5 包 ...
- sed命令使用示例
sed -i '/mirrorlist/d' CentOS-Base-163.repo 把有mirrorlist的行删除sed -i '/\[addons\]/,/^$/d' CentOS-Base- ...
- 在CcentOS系统上将deb包转换为rpm包
deb文件格式本是ubuntu/debian系统下的安装文件,那么我想要在redhat/centos/fedora中安装,需要把deb格式的软件包转化成rpm格式. 需要用到的转换工具:alien_8 ...
- javascript 回车实现 tab 切换功能完美解决
最经有一个项目是给化工厂做的在使用的过程中需要输入大量的数据,使用的都是小键盘区,在以前都是通过excel录入数据的现在, 在网页上需要实现excel 那样的回车换行的功能在网上找了有关这方面的问题但 ...
- elasticsearch 基础性操作
1 基础概念 Elasticsearch是一个近实时的系统,从你写入数据到数据可以被检索到,一般会有1秒钟的延时.Elasticsearch是基于Lucene的,Lucene的读写是两个分开的句柄,往 ...
- 自定义ViewPager的兼容性问题及解决办法
通过它我们可以给图片增加组合动画效果,也可以写成一个图片查看器. 比如我们首次安装应用的时候,很多就会用到ViewPager给我们做一个应用简介.今天要写的也是这个--怎么用ViewPager实现动画 ...
- ARM指令中的函数调用
1. 重要寄存器 SP 栈指针, 每一种异常模式都有其自己独立的r13,它通常指向异常模式所专用的堆栈,也就是说五种异常模式.非异常模式(用户模式和系统模式),都有各自独立的堆栈,用不同的堆栈指针来 ...