標籤:style io ar os 使用 sp for on div
使用NavigationViewController進行頁面跳轉時,應該使用pushViewController方法來跳轉至下一頁面,這樣的話,下一頁面同樣在NavigationViewController容器中。
1、跳轉到下一頁面:
- AloneSetPrizeViewController *setPrize = [[AloneSetPrizeViewController alloc] init];
- // 所要跳轉頁面<span style="font-family: Arial, Helvetica, sans-serif;"> AloneSetPrizeViewController中有個屬性dictionary1是個NSMutableDictionary類型的容 器</span>
- [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];
- }
ios--NavigationViewController跳轉、返回傳值