如何从Modal ViewController重新加载父UITableViewController中的数据 [英] How to reload data in parent UITableViewController from Modal ViewController

查看:123
本文介绍了如何从Modal ViewController重新加载父UITableViewController中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有根视图控制器(UITableViewController)的导航控制器。此表视图控制器具有到另一个导航控制器的模态segue,其中UITableViewController作为根视图控制器。从我的模态表视图控制器,我正在调用

I have a navigation controller with a root view controller (UITableViewController). This table view controller has a modal segue to another navigation controller with a UITableViewController as the root view controller. From my modal table view controller, I am calling

[self dismissModalViewControllerAnimated:YES];

关闭模型视图。我想在解开模态视图之前调用我的刷新函数(位于第一个UITableViewController中)。我尝试使用

to dismiss the model view. I am trying to, prior to dismissing the modal view, call my "refresh" function (which is located in the first UITableViewController). I tried using

[self.parentViewController refresh];

但我猜我现在指的是模态视图的导航控制器?它似乎不适用于这个原因。

but I am guessing that I am then referring to the navigation controller of the modal view? It doesn't seem to be working for that reason.

推荐答案

创建一个 NSNotificationCenter 在父视图中:

Create an NSNotificationCenter in your parent view:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refresh) name:@"updateParent" object:nil];

然后在你解雇模态视图时调用它:

Then call it when you dismiss the modal view:

[[NSNotificationCenter defaultCenter] postNotificationName:@"updateParent" object:nil];

这篇关于如何从Modal ViewController重新加载父UITableViewController中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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