How does one access a super's view controller?

后端 未结 1 1088
小蘑菇
小蘑菇 2020-12-30 09:35

I have a problem and I will try to explain the issue:

  1. I have one main UIViewController (Whole screen)
  2. I have one secondary UIViewCo
相关标签:
1条回答
  • 2020-12-30 09:57

    In your secondary controller, try

    id mainViewController = [self.view.superview nextResponder];
    

    and check if this is the view controller 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)

    0 讨论(0)
提交回复
热议问题