Is there any way to get class name of parent VC in present (child) UIViewController
? My \'child\' VC (push) has two \'parent\'UIViewController
s, so I w
UPDATED TO SWIFT 5
In your child view controller, you could try something like:
guard let parent = self.presentingViewController else{
// ...some code
return
}
//presented by parent view controller 1
if parent.isKind(of: Parent1.self){
// do something
}else{
//presented by parent view controller 2
}
I recommend you to place this logic in your viewWillAppear
method because when viewDidLoad
is called, there is no guarantee that the view controller hierarchy is loaded in the navigation tree and like a consequence of this, the presentingViewController
property of your child view controller might be nil