Check if superview is UITableViewController UIViewController?

673 views Asked by At

I have a custom class I created. Is there a way to check if it's superview is a UITableViewController, or a `UIViewController?

1

There are 1 answers

5
Doro On BEST ANSWER

You can access nextResponder property of your superview

[self.view.superview nextResponder];

or if in custom class

[self.superview nextResponder];

and check throw isKindOfClass if this is the view controller type you're looking for.

Apple's documentation of -[UIResponder nextResponder]:

UIView implements this method by returning the UIViewController object that manages it (if it has one) or its superview (if it doesn’t)