NavigationViewController

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

1、跳转到下一页面:

?
1
2
3
4
5
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、从当前页面返回到上一页面并传值过去:

?
1
2
3
4
5
6
7
8
//此页面已经存在于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中进行判断并接收传递的值:

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

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

?
1
2
3
4
5
//返回到上一界面
-(IBAction)backOff:(id)sender
{
     [self.navigationController popViewControllerAnimated: true ];
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值