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

     

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

    1、跳转到下一页面:

     
    1. AloneSetPrizeViewController *setPrize = [[AloneSetPrizeViewController alloc] init];  
    2. // 所要跳转页面<span style="font-family: Arial, Helvetica, sans-serif;"> AloneSetPrizeViewController中有个属性dictionary1是个NSMutableDictionary类型的容 器</span>  
    3. [setPrize.dictionary1 setObject:[self.txtPassWd text] forKey:ALONE_SITEPRIZE_PWD];  
    4. //使用pushViewController跳转到下一页面  
    5. [self.navigationController pushViewController:setPrize animated:true];  


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

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

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

     
    1. -(void)viewDidAppear:(BOOL)animated  
    2. {  
    3.   //判断并接收返回的参数  
    4.   
    5. }  


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

     
      1. //返回到上一界面  
      2. -(IBAction)backOff:(id)sender  
      3. {  
      4.     [self.navigationController popViewControllerAnimated:true];  
  • 相关阅读:
    tmp
    GO语言中使用OpenCV
    The OpenCV Coding Style Guide
    下载tree命令的源代码
    convention over configuration 约定优于配置 按约定编程 约定大于配置 PEP 20 -- The Zen of Python
    tmp
    起步依赖
    Spring Boot Dubbo Dubbok spring cloud
    pug.compile() will compile the Pug source code into a JavaScript function that takes a data object (called “locals”) as an argument.
    request /a?b= /a/?b=
  • 原文地址:https://www.cnblogs.com/keyan1102/p/4162083.html
Copyright © 2011-2022 走看看