如何通过 iOS Objective C 中的 appDelegate 从另一个视图控制器重新加载 table 视图

How to reload table view from another view controller via appDelegate in iOS Objective C

我正在尝试从我的 FirstViewController 重新加载我的 SingleGrid 的 UITableViewUITableView 的声明是 IBOutlet 并且在我的 AppDelegate 中声明了 singleGrid 变量。 我想从 FirstViewController.Table 视图名称 singleGridTable 重新加载 singleGrid 的 UITableView 不在点之后。

appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

[appDelegate.singleGrid.singleGridTable reloadData]

更多代码可能会有所帮助(相关 headers 和实现),但我可以在黑暗中拍摄。 firstViewController 是否知道 SingleGrid 上存在哪些属性?无论你想在 SingleGrid 上访问 属性,你都需要包含声明 属性 存在的 header。你的 firstViewController 也是如此 ha

确保您已在 appdelegate.h 中将 singleGrid 声明为 属性,例如

@property (nonatomic, strong) SingleGridViewController * SingleGrid;

那些在 .h 文件中声明的属性是 public 否则它们是私有的,您无法在其他 类.

中访问它们

还要确保在您的 .h 文件中也将 singleGridTable 声明为 属性。

@property (nonatomic, weak) IBOutlet UITableView * singleGridTable;