Within my viewDidLoad
I would like some custom code based upon the previous controller.
How can I access the segue source controller or the previous segue identifier in the destination controller's viewDidLoad to handle this?
Within my viewDidLoad
I would like some custom code based upon the previous controller.
How can I access the segue source controller or the previous segue identifier in the destination controller's viewDidLoad to handle this?
There is no way to get a reference to the segue that created you. You could create a property (sourceVC in my example) in the destination controller, and assign self to this property in the prepareForSegue method (in the source view controller):
[(DestinationVCClass *)segue.destinationViewController sourceVC] = self;
You can just use [self presentingViewController]
and you'll be able to access the VC that issued the segue. I usually like to couple it with isMemberOfClass:
for a situation like this.
You do the following in the unwinding segue method in the destination
self.source = (UIStoryboardSegue *)segue.sourceViewController;
Define source as a UIStoryboardSegue in the destination. The above line will give the source or the previous segue.
© 2022 - 2024 — McMap. All rights reserved.