I have three view controllers that push each other on to the navigation controller.
ViewController1 may push VC2 or VC3 VC2 may push VC3
That means, either VC3 is opened by VC1 or VC2. VC1 is a subclass of UITableViewController and VC2 is a subclass开发者_如何学Python of UIViewController.
Now, in VC3 I want to know if VC1 or VC2 created VC3. How can I do that?
You could check;
[vc3 parentViewController];
that returns a UIViewController
.
According to what you need, you may do
if ([[vc3 parentViewController] isKindOfClass:[VC1 class]]) {
//has been pushed by VC1
}
else if ([[vc3 parentViewController] isKindOfClass:[VC2 class]]) {
//has been pushed by VC2
}
精彩评论