gpt4 book ai didi

objective-c - 如何识别导航堆栈中的前一个 View Controller

转载 作者:IT老高 更新时间:2023-10-28 11:23:28 27 4
gpt4 key购买 nike

我有 2 个单独的 navigationcontrollers,一个带有 RootViewController A,另一个带有 RootViewController B。

我可以将 ViewController C 推送到 A 或 B 的导航堆栈中。

问题:当我在ViewController C中时,如何知道我是在属于A还是B的栈中?

最佳答案

您可以使用 UINavigationControllerviewControllers 属性:

@property(nonatomic, copy) NSArray *viewControllers

Discussion: The root view controller is at index 0 in the array, the back view controller is at index n-2, and the top controller is at index n-1, where n is the number of items in the array.

https://developer.apple.com/documentation/uikit/uinavigationcontroller

您可以使用它来测试 Root View Controller (数组索引为 0 的那个)是 View Controller A 还是 B。

关于objective-c - 如何识别导航堆栈中的前一个 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7005787/

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