当模态视图被解除时的方法 [英] Method for when the modal view has been dismissed

查看:18
本文介绍了当模态视图被解除时的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个带有模态视图的应用程序,我可以显示然后关闭它.有没有一种简单的方法可以知道模态视图何时被解除?我想在模式视图被关闭后重新加载表中的数据,但不知道这样做的最佳方法.

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 reload the data in a table once the modal view has been dismissed and don't know the best way of doing this.

谢谢

推荐答案

UIViewController 有一个名为 parentViewController 的属性.在视图控制器以模态呈现的情况下,parentViewController 属性指向呈现模态视图控制器的视图控制器.

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.

在您的模态视图控制器中,在 viewWillDisappear: 中,您可以向 parentViewController 发送消息以执行您想要的任何操作,本质上.

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

类似于:

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

如果您的父视图控制器是表视图控制器,那么您应该能够调用 [self.parentViewController.tableView reloadData]; 来完成您想要实现的目标.

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.

这篇关于当模态视图被解除时的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆