Access modal view controller parent

后端 未结 6 1210
傲寒
傲寒 2021-02-01 04:05

I\'m presenting a ViewController modally. How can I access the parent view controller ?

My architecture is TabBarController=>VC1=>VC2=>VC3=>MVC1, and I want to reach VC3

6条回答
  •  说谎
    说谎 (楼主)
    2021-02-01 05:12

    The way I'd go about something like this is to simply create a delegate. In AskPasswordViewController's header, put

    id delegate;
    

    and

    @property (nonatomic, assign) id delegate;
    

    Synthesize it in the implementation file. Then after you alloc/init the modal controller, and before you present it, set modalViewController.delegate = self;. Then within the modal controller, you can call self.delegate to get information from the view controller that presented it. I hope this helps

提交回复
热议问题