UINavigationcontroller -在堆栈上改变UIViewController的状态。

时间:2021-12-22 23:10:54

I have a navigation controller that displays viewcontroller A. There is a right button (labelled "B") that leads to viewcontroller B.

我有一个导航控制器,它显示视图控制器a。有一个右按钮(标签为B),它会引导到viewcontroller B。

Now, when the user makes an important change in (the view managed by) viewcontroller B, viewcontroller B's usefulness has ended.

现在,当用户在视图控制器B中做出重要的改变时,viewcontroller B的有用性就结束了。

From then on, VC A should lead to a new VC, viewcontroller C. This is the behavior that I want. However, because viewcontroller A has already been created with a right button leading to "B", I'm not sure how to get it to re-configure itself. I want it to now have a right button labeled "C" which leads to viewcontroller C.

从那以后,VC A就会产生一个新的VC, viewcontroller。这就是我想要的行为。但是,因为viewcontroller A已经被创建了一个正确的按钮,导致“B”,所以我不知道如何让它重新配置自己。我希望它现在有一个标签为“C”的右按钮,它会引导到viewcontroller C。

I have been unable to find any sample code that addresses a situation like this. To boil the problem down to its essence, I just need to be able to re-make viewcontroller A while it's in the navcontroller's stack.

我一直找不到任何能解决这种情况的样本代码。要把问题归结到它的本质,我只需要能够在navcontroller的堆栈中重新创建viewcontroller。

1 个解决方案

#1


0  

You can store a reference to controller A in your application delegate and, when controller B is finished, change controller A's navigation item like appdelegate.controllerA.navigationItem.rightBarButtonItem = /* a new bar button item to create and push controller C goes here ... */.

您可以在应用程序委托中存储对控制器a的引用,当控制器B完成时,更改控制器a的导航项,如appdelegate.controllerA.navigationItem。在这里创建和推动控制器C的新栏按钮项。* /。

#1


0  

You can store a reference to controller A in your application delegate and, when controller B is finished, change controller A's navigation item like appdelegate.controllerA.navigationItem.rightBarButtonItem = /* a new bar button item to create and push controller C goes here ... */.

您可以在应用程序委托中存储对控制器a的引用,当控制器B完成时,更改控制器a的导航项,如appdelegate.controllerA.navigationItem。在这里创建和推动控制器C的新栏按钮项。* /。