Objective c 如何从AppDelegate.m重新加载TableView数据?
我尝试从AppDelegate.m重新加载TableView数据,但没有成功 以下是在HomeViewController中工作的代码: AppDelegate.m 有人知道如何从AppDelegate.m重新加载数据吗?您可以实现Objective c 如何从AppDelegate.m重新加载TableView数据?,objective-c,xcode,uitableview,Objective C,Xcode,Uitableview,我尝试从AppDelegate.m重新加载TableView数据,但没有成功 以下是在HomeViewController中工作的代码: AppDelegate.m 有人知道如何从AppDelegate.m重新加载数据吗?您可以实现 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadTableViewData) name:@"ReloadAppDelegateTable" object:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadTableViewData) name:@"ReloadAppDelegateTable" object:nil];
在viewDidLoad方法和
- (void)reloadTableViewData{
[self.myTableView reloadData];
}
在要重新加载数据的类中
然后你发送这样的通知
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReloadAppDelegateTable" object:nil];
每当您想要重新加载数据时
注意:经过几年的iOS开发经验后:
虽然这是一个非常简单和舒适的解决方案,但它不是100%可靠的。在某些情况下,通知可能会延迟几秒钟。我强烈建议您创建到UITableViewController的快速可靠的代理连接
你可以实施
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadTableViewData) name:@"ReloadAppDelegateTable" object:nil];
在viewDidLoad方法和
- (void)reloadTableViewData{
[self.myTableView reloadData];
}
在要重新加载数据的类中
然后你发送这样的通知
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReloadAppDelegateTable" object:nil];
每当您想要重新加载数据时
注意:经过几年的iOS开发经验后:
虽然这是一个非常简单和舒适的解决方案,但它不是100%可靠的。在某些情况下,通知可能会延迟几秒钟。我强烈建议您创建到UITableViewController的快速可靠的代理连接
为什么尝试在appdelegate中执行该调用?home.myTableView是有效对象?为什么尝试在appdelegate中执行该调用?home.myTableView是有效对象?此代码正在运行,但TableView中的数据未更改。你知道为什么会这样吗?一切都好,都是我的错。我尚未将od IB myTableView连接到插座:谢谢!效果很好..:此代码正在运行,但TableView中的数据未更改。你知道为什么会这样吗?一切都好,都是我的错。我尚未将od IB myTableView连接到插座:谢谢!效果很好..: