zoukankan      html  css  js  c++  java
  • ios--NavigationViewController跳转、返回传值

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

         1、跳转到下一页面:

    AloneSetPrizeViewController *setPrize = [[AloneSetPrizeViewController alloc] init];
    //所要跳转页面AloneSetPrizeViewController中有个属性dictionary1是个NSMutableDictionary类型的容器
    [setPrize.dictionary1 setObject:[self.txtPassWd text] forKey:ALONE_SITEPRIZE_PWD];
    //使用pushViewController跳转到下一页面
    [self.navigationController pushViewController:setPrize animated:true];

        2、从当前页面返回到上一页面并传值过去:

    //此页面已经存在于self.navigationController.viewControllers中,并且是当前页面的前一页面   
    AloneSetSiteViewController *setPrizeVC = [self.navigationController.viewControllers objectAtIndex:self.navigationController.viewControllers.count-2];
    //初始化其属性
    setPrizeVC.dictionary = nil;
    //传递参数过去
    setPrizeVC.dictionary = [NSMutableDictionary dictionaryWithDictionary:self.dictionary1];
    //使用popToViewController返回并传值到上一页面
    [self.navigationController popToViewController:setPrizeVC animated:true];

         返回到上一页后,上一页面显示后要接收参数,并刷新。注意此时应该在viewDidAppear中进行判断并接收传递的值:

    -(void)viewDidAppear:(BOOL)animated
    {
      //判断并接收返回的参数
     
    }

         3、从当前页面返回到上一页面(无需传值)的方法:

    //返回到上一界面
    -(IBAction)backOff:(id)sender
    {
        [self.navigationController popViewControllerAnimated:true];
    }
  • 相关阅读:
    java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Date
    权限控制-JS判断是否有权限进行操作跳转页面需要加target
    为你的网站装个“头像”
    本地存储由来的背景
    HTML5的新的结构元素介绍
    Canvas绘图API
    HTML5文件操作API
    认识HTML5
    基于scrapy爬虫的天气数据采集(python)
    Python strip()方法
  • 原文地址:https://www.cnblogs.com/tangaofeng/p/4928211.html
Copyright © 2011-2022 走看看