(一)使用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
{
  //推断并接收返回的參数
 
}

3、从当前页面返回到上一页面(无需传值)的方法:
//返回到上一界面
-(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跳转以及返回传值的更多相关文章

  1. ios--NavigationViewController跳转、返回传值

      使用NavigationViewController进行页面跳转时,应该使用pushViewController方法来跳转至下一页面,这样的话,下一页面同样在NavigationViewContr ...

  2. iOS Scheme 跳转主流实现方案

    iOS Scheme跳转主流实现方案主要是路由跳转,目前iOS常用路由框架是JLRouter.HHRouter.MGJRouter. 但是这些路由库都各有不足,首先是JLRouter,用不到的功能繁多 ...

  3. iOS界面跳转的一些优化方案

    原文地址: http://blog.startry.com/2016/02/14/Think-Of-UIViewController-Switch/ iOS界面跳转的一些优化方案 App应用程序开发, ...

  4. Android——关于Activity跳转的返回(无返回值和有返回值)——有返回值

    说明: 跳转页面,并将第一页的Edittext输入的数据通过按钮Button传到第二页用Edittext显示,点击第二页的 返回按钮Button返回第一页(改变第二页的Edittext的内容会传至第一 ...

  5. iOS页面跳转及数据传递

    转: http://blog.csdn.net/wang9834664/article/details/8025571 iOS页面跳转: 第一种 [self.navigationController  ...

  6. iOS 10 跳转系统设置

    苦心人天不负, 为了项目终于把 iOS 10 跳转系统设置的方法给搞定了, 很欣慰. http://www.cnblogs.com/lurenq/p/6189580.html iOS 10 跳转系统设 ...

  7. ios页面跳转

    reference:http://blog.csdn.net/engandend/article/details/11706323 目前,就我所学到的内容,页面跳转有三种方法 一.直接推到下一个页面 ...

  8. react-router(v4) 路由跳转后返回页面顶部问题

    遇到的问题 由A页面跳转到B页面,B页面停留在A页面的位置,没有返回到顶部. 问题分析 首先分析下出现此问题的原因: 在项目中使用的是 hashHistory,它是建立在 history 之上的,当路 ...

  9. 移动端开发在iOS系统中 new Date() 返回 NaN 的问题

    问题: 通过 new Date() 函数将后台返回的时间('2021-11-25')获取时间戳.在 chrome 浏览器的手机模拟器中没有出现问题,但在 iPhone 真机测试的时候,显示的结果不符合 ...

随机推荐

  1. Python学习笔记——对象

    Python 的对象定义方式如下: class Person:        def __init__(self, name):            self.name = name         ...

  2. linux之ssh命令

    ssh命令用于远程登录上Linux主机. 常用格式:ssh [-l login_name] [-p port] [user@]hostname更详细的可以用ssh -h查看. 不指定用户: ssh 1 ...

  3. pr_debug、dev_dbg等动态调试一

    内核版本:Linux-3.14 作者:彭东林 邮箱:pengdonglin137@163.com pr_debug: #if defined(CONFIG_DYNAMIC_DEBUG) /* dyna ...

  4. iOS8使用TestFlight进行内部测试功能尝鲜

    iOS8发布了有一段时间了,我们的策划很新潮的速度给升级到iOS8了.于是XCode5不支持了,只好从MacOS 10.8升级到10.9,再升级到10.9.5,再下载XCode6安装…… 然后前两天上 ...

  5. Android Facebook分享功能实现

    1.下载 Facebook SDK https://developers.facebook.com/docs/Android?locale=zh_CN 2.在facebook下设置app的相关信息 3 ...

  6. POJ 3486 & HDU 1913 Computers(dp)

    题目链接:PKU:HDU: PKU:http://poj.org/problem?id=3486 HDU:pid=1913" target="_blank">htt ...

  7. HTML5 资源导航

    1,百度百科 http://baike.baidu.com/view/951383.htm 2,w3school http://www.w3school.com.cn/html5/ 3, HTML5 ...

  8. 使用springMVC上传文件

    control层实现功能: @RequestMapping(value="upload2") public String upLoad2(HttpServletRequest re ...

  9. fiddler实现后端接口 mock(不需要修改开发代码)

    转载:http://blog.csdn.net/huazhongkejidaxuezpp/article/details/50435552 步骤   1.  获取 接口 定义(接口返回的json串) ...

  10. C++使用SQLite步骤及示例

    C++使用SQLite步骤及示例开发环境:Windows 10+VS2013. 开发语言:C++.   1. 下载sqlite文件. 下载网址:http://www.sqlite.org/downlo ...