Method for when the modal view has been dismissed

后端 未结 2 1592
广开言路
广开言路 2020-12-30 03:32

I have created an application with a modal view that I can display and then dismiss. Is there an easy way to know when the modal view has been dismissed? I would like to rel

2条回答
  •  粉色の甜心
    2020-12-30 04:09

    UIViewController has a property called parentViewController. In the case that a view controller is presented modally, the parentViewController property points to the view controller that presented the modal view controller.

    In your modal view controller, in viewWillDisappear: you can send a message to the parentViewController to perform any action you wish, essentially.

    Something like:

    - (void)viewWillDisappear:(BOOL)animated
    {
        [super viewWillDisappear:animated];
        [self.parentViewController doSomething];
    }
    

    If your parent view controller is a table view controller, then you should be able to call [self.parentViewController.tableView reloadData]; to do what you're trying to achieve.

提交回复
热议问题