2

viewDidAppear从后台返回到我的 iPhone 应用程序后,方法没有被调用。

有人对此有解决方案吗?

每次MainViewController显示 my 时(即使从后台返回后),我都需要调用一个方法,该方法会将标签更改为新日期。

viewDidAppear似乎无法正常工作。

4

3 回答 3

1

实际上它工作正常。

UIApplicationDidBecomeActiveNotification相反,请考虑为or安装通知处理程序UIApplicationWillEnterForegroundNotification,这可能更适合您的情况。从那里您可以更新您的 GUI。

于 2013-05-14T00:46:30.890 回答
0

You will have the UIApplicationWillEnterForegroundNotification method in App delegate.Now you need to create the object of the class you want and call the viewwillAppear

this method will be called when the app is in background.

- (void)applicationDidEnterBackground:(UIApplication *)application
{
}

now for the view will appear code like this

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    ViewController *vc = [ViewController alloc]init];//you can use your viewcontroller here

    [vc viewDidAppear:YES];// this will call the method.
}
于 2013-05-14T03:46:38.190 回答
0

如果您不介意在实际显示之前执行此过程,请尝试使用 viewWillAppear。否则,您可以使用该方法。- (void)applicationWillEnterForeground:(UIApplication *)application{}

于 2013-05-14T08:54:08.033 回答