gpt4 book ai didi

ios - 呈现 View Controller 时状态恢复不起作用?

转载 作者:搜寻专家 更新时间:2023-10-30 20:14:07 25 4
gpt4 key购买 nike

我没有使用 Storyboard。目前在 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];

并且在InnerViewController中给出了restorationIdentifierrestorationClass。我有适当的恢复方法。比如

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

一切都很好

present 有什么特别的要求吗??

最佳答案

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

在您的特定情况下,请确保在恢复内部 NC 时,它在返回到操作系统之前也被分配了 @"innerNavSR"标识符。

希望对您有所帮助。

关于ios - 呈现 View Controller 时状态恢复不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39997798/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com