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

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

问题描述

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

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天全站免登陆