• NavigationViewController页面间通信及传值


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

    1AloneSetPrizeViewController *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];

    }

  • 相关阅读:
    最精简的django程序
    spring+mongo
    从零搭建mongo分片集群的简洁方法
    java对redis的基本操作
    awk输出指定列
    sed输出指定行
    Bash的循环结构(for和while)
    用ffmpeg切割音频文件
    Python判断字符串是否全是字母或数字
    Python函数: any()和all()的用法
  • 原文地址:https://www.cnblogs.com/littlewrong/p/4909017.html
Copyright © 2020-2023  润新知