opening and closing other UIViewControllers - any other approaches than to use protocol & delegate?

前端 未结 2 1783
清歌不尽
清歌不尽 2021-01-15 19:17

The normal way to open another screen from within a FirstVC screen, so one can close it again is like this:

    SecondVC *secondVC = [[SecondVC alloc] initWi         


        
2条回答
  •  半阙折子戏
    2021-01-15 19:59

    What you describe is not the easiest pattern. Actually you should do something very similar to what you suggested would be nice. When SecondVC is ready to be dismissed it just calls, for example:

    [self dismissViewControllerAnimated:YES completion:NULL];
    

    From the UIViewController documentation:

    The presenting view controller is responsible for dismissing the view controller it presented. If you call this method on the presented view controller itself, it automatically forwards the message to the presenting view controller.

提交回复
热议问题