4

我没有使用故事板。目前在 ViewController1 中。在按钮单击事件中,我调用此代码。

InnerViewController *innerVc = [[InnerViewController alloc]  initWithNibName:@"InnerViewController" bundle:nil titleText:@"vaibhav"];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:innerVc];
    nav.restorationIdentifier = @"innerNavSR";
    [self.navigationController presentViewController:nav animated:YES completion:nil];

并在 InnerViewControllerrestorationIdentifierrestorationClass给出。我为恢复编写了适当的方法。比如

viewControllerWithRestorationIdentifierPath
encode and decode restoration. 

如果我改变我的

[self.navigationController presentViewController:nav animated:YES completion:nil];

[self.navigationController pushViewController:innerVc animated:YES];

它工作正常。我现在错过了什么或做错了什么。为了尝试,我什至试过这个:

[self presentViewController:nav animated:YES completion:nil];

但是没有用。不工作。

演示时的结果是 -

viewControllerWithRestorationIdentifierPath

并被decodeRestorableStateWithCoder调用。电话也进来了,viewdidload但没有进来viewwillappear。我在视觉上看到Viewcontroller1。然而这一切都很好push

礼物需要什么特别的东西 吗?

4

1 回答 1

3

我有一个非常相似的问题,并且挣扎了半天。问题是我在定期创建视图控制器时分配了一个恢复标识符,但在创建恢复的实例时没有分配它。

在您的特定场景中,请确保在恢复内部 NC 时,在将其返回给操作系统之前,还会为其分配 @"innerNavSR" 标识符。

希望有帮助。

于 2016-11-10T18:21:05.950 回答