Can we detect controller is open or load from which mode segue or navigation.
Detect Segue or Navigation
I don't understand why you need it.
You could do it programmatically.
In the destination controllers, test for self.navigationController in viewDidload:
If the destination is in a navigation stack, it is not nil.
If it comes from a "pure" segue, it will be nil.
However, if the originating VC is in a navigation stack, it will not be nil.
To differentiate in that case, you would need to add a property in the destination
and set it true in the prepare for segue.
Note: you could encapsulate all this into a UIViewController subclass, overriding viewDidLoad
You could do it programmatically.
In the destination controllers, test for self.navigationController in viewDidload:
Code Block print(self.navigationController == nil ? "not nav" : "nav")
If the destination is in a navigation stack, it is not nil.
If it comes from a "pure" segue, it will be nil.
However, if the originating VC is in a navigation stack, it will not be nil.
To differentiate in that case, you would need to add a property in the destination
Code Block var comesFromSegue : Bool = false
and set it true in the prepare for segue.
Note: you could encapsulate all this into a UIViewController subclass, overriding viewDidLoad
Code Block var comesFromSegue : Bool? // Must be set in prepare; we assume here that there are only 2 cases: segue of nav override func viewDidLoad() { super.viewDidLoad() if comesFromSegue == nil { // Then it was NOT set in a prepare, but segue we could be in a navigation stack anyway comesFromSegue = self.navigationController == nil // Do we really come from a navigation ? Otherwise, we assume it is segue } // else { comesFromSegue = true } as set in prepare }
Did this solve your issue ?
If so, don't forget to mark the correct answer in order to close the thread.
If so, don't forget to mark the correct answer in order to close the thread.