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?
This segue is relevant only for view controllers embedded inside a UISplitViewController object. With this segue, a split view controller replaces its second child view controller (the detail controller) with the new content. Most other view controllers present the new content modally.
During a segue, you can use the identifier to determine which segue was triggered, which is especially useful if your view controller supports multiple segues. The identifier is included in the UIStoryboardSegue object delivered to your view controller when the segue is performed.
For most view controllers, this segue presents the new content modally over the source view controller. Some view controllers specifically override the method and use it to implement different behaviors. For example, a navigation controller pushes the new view controller onto its navigation stack.
The segue, which is an object, is passed as a parameter to that method. Through its destination property, you can access the destination view controller. The destination view controller needs to declare a public stored property to receive data. First of all, let’s set up the destination view controller. @IBOutlet var imageView: UIImageView?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With