gpt4 book ai didi

ios - 从 Presentmodelview 堆栈中移除 UIViewcontroller

转载 作者:行者123 更新时间:2023-11-29 00:25:25 24 4
gpt4 key购买 nike

我想从当前模型 View 堆栈中删除 UIViewcontroller

我有下面的场景

UIViewcontrollerA 
UIViewcontrollerB
UIViewcontrollerA
UIViewcontrolleC
UIViewcontrolleA
UIViewcontrolleA

我想从这个呈现的 View Controller 中删除所有 UIViewcontrolleA。

我如何获得这些?所以输出将是

 UIViewcontrollerB 
UIViewcontrolleC

我可以在导航 Controller 中轻松完成此操作,在presentmodelcontroller中也需要类似的操作。

NSMutableArray *allViewControllers = [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
[allViewControllers removeObjectAtIndex:0];
[allViewControllers removeObjectAtIndex:1];

[self.navigationController setViewControllers:allViewControllers animated:YES];

最佳答案

dismiss​View​Controller​Animated:​completion:​在 vc 上调用时将删除它以及它上面显示的任何内容。

A->B->C->D->E

所以要关闭,比如上面堆栈中的 D 和 E,只需在 C 上调用关闭。要恢复 D 和 E,请在没有动画的情况下再次呈现它们。您需要自己跟踪这个 A、B、C...数组。

另请注意,您在 SDK 中看到对此的支持如此之少这一事实表明不鼓励该想法。

关于ios - 从 Presentmodelview 堆栈中移除 UIViewcontroller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43157234/

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