在[self.navigationController popToRootViewControllerAnimated:YES]期间分配变量;

时间:2013-11-11 13:01:39

标签: ios segue poptoviewcontroller

我正在寻找一种在调用[self.navigationController popToRootViewControllerAnimated:YES];时分配ivar的方法,类似于在调用segue时如何设置值:

if ([segue.identifier isEqualToString:@"login"]) {
    [sender resignFirstResponder];
    HomeController * home = (HomeController *)segue.destinationViewController;
    home.personHome = self.person;

}

我在哪里分配对象变量。当前架构使用[self.navigationController popToRootViewControllerAnimated:YES];

当应用程序加载HomeController时,它是第一个视图,但在其视图中,它调用[self performSegueWithIdentifier:@"login" sender:self];的Load方法进入登录屏幕。成功登录回弹。

非常感谢建议和指导。

2 个答案:

答案 0 :(得分:1)

这有效:

HomeController *myController = (HomeController *)[self.navigationController.viewControllers objectAtIndex:0];
myController.personHome =self.person ;
[self.navigationController popToViewController:myController animated:YES];

答案 1 :(得分:0)

这就是我在Swift 2.2中的工作方式:

let myController = self.navigationController?.viewControllers[0] as! HomeController
myController.personHome = self.person
self.navigationController?.popToRootViewControllerAnimated(true)