Presenting a modal view controller immediately after dismissing another

后端 未结 8 1847
渐次进展
渐次进展 2020-12-02 12:59

I\'m dismissing a modal view controller and then immediately presenting another one, but the latter never happens. Here\'s the code:

 [self dismissModalViewContro         


        
8条回答
  •  没有蜡笔的小新
    2020-12-02 13:46

    In this case, I create delegate to callback parent view controller to show the second modal view controller.

    Definition protocol of the parent view controller:

    @protocol ParentViewControllerDelegate
    - (void)showModalTwo;
    @end
    

    I implement this protocol in the parent view controller to show the second modal view controller and create the delegate property @property id delegate; on the first modal view controller.

    Show the first modal view controller from parent view controller:

    TheFirstModalViewController *controller = ...
    controller.delegate = self;
    [self presentViewController:controller animated:YES completion:nil];
    ...
    

    On viewDidDisappear: method of the first modal view controller, just call delegate.showModalTwo: to show the second modal view from parent view controller.

    Hope this help.

提交回复
热议问题