我没有使用故事板。目前在 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];
并在 InnerViewControllerrestorationIdentifier
中restorationClass
给出。我为恢复编写了适当的方法。比如
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
礼物需要什么特别的东西 吗?