Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have 2 seperate navigationcontrollers, one with RootViewController A and the other with RootViewController B.

I am able to push ViewController C onto either A or B's navigation stack.

Question: When I am in ViewController C, how can I find out if I am in the stack belonging to A or B?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
489 views
Welcome To Ask or Share your Answers For Others

1 Answer

You could use the UINavigationController's viewControllers property:

@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

You could use that to test whether the root view controller (the one at array index 0) is view controller A or B.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...