Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS中的基本表程序-如何告诉我的表从应用程序委托重新加载数据?_Ios_Uitableview_Uiapplicationdelegate - Fatal编程技术网

iOS中的基本表程序-如何告诉我的表从应用程序委托重新加载数据?

iOS中的基本表程序-如何告诉我的表从应用程序委托重新加载数据?,ios,uitableview,uiapplicationdelegate,Ios,Uitableview,Uiapplicationdelegate,我现在已经创建了您的标准表应用程序。窗口有一个UINavigationController作为其rootViewController,并且该UINavigationController已使用其rootViewController作为我的自定义UITableController初始化 我的应用程序表数据随时间而变化。如果我从挂起状态打开应用程序,那么我的数据就过时了。如何让ApplicationWillEnter前台更新我的数据?我尝试了一些尴尬的事情,比如 - (BOOL)application

我现在已经创建了您的标准表应用程序。窗口有一个UINavigationController作为其rootViewController,并且该UINavigationController已使用其rootViewController作为我的自定义UITableController初始化

我的应用程序表数据随时间而变化。如果我从挂起状态打开应用程序,那么我的数据就过时了。如何让ApplicationWillEnter前台更新我的数据?我尝试了一些尴尬的事情,比如

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    HabitsTable* vc = [[HabitsTable alloc] init];
    [vc initCoreData];
    UINavigationController* nav = [[UINavigationController alloc]      initWithRootViewController:vc];
    self.window.rootViewController = nav;
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
        [[[[self window] rootViewController] navigationController] rootViewController]
}

但是,毫不奇怪,这是行不通的。我不知道如何使用UITableController?

我建议使用。您可以看到如何使用该类的一个很好的示例。

我建议使用。您可以看到一个很好的示例,说明如何使用该类。

我相信您的尝试:

UINavigationController *navController = (UINavigationController*)[[self window] rootViewController];
HabitsTable *tableView = (HabitsTable*)[navController topViewController];

我相信你的亲密尝试:

UINavigationController *navController = (UINavigationController*)[[self window] rootViewController];
HabitsTable *tableView = (HabitsTable*)[navController topViewController];

伙计,这很有帮助。了解NSNotificationCenter可能会让我现在重构整个应用程序。谢谢伙计,这很有帮助。了解NSNotificationCenter可能会让我现在重构整个应用程序。谢谢啊,topViewController。这很可能就是我想要的。我想我会改用NSNotificationCenter,因为这样可能会减少代码重复。啊,topViewController。这很可能就是我想要的。我想我会改用NSNotificationCenter,因为这样可能会减少代码重复。