1

我想要做的是告诉用户按下主页按钮并重新打开应用程序,这需要应用程序在进入后台时退出 - 这是为了重置应用程序设置。但我确实希望该应用程序在所有其他时间都处于后台。我是否使用应用程序委托?

如果有更简单的方法,例如以某种方式重新启动主视图控制器,那将很有帮助。

4

1 回答 1

0
    For your app to run in background always use this code.
    Put this code under the method ApplicationDidEnterBackground  in your app delegate class            .m file
- (void)applicationDidEnterBackground:(UIApplication *)application
{
     UIApplication *app = [UIApplication sharedApplication];
        UIBackgroundTaskIdentifier bgTask = 0;
        bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
            [app endBackgroundTask:bgTask];
        }];

}
于 2013-07-31T10:36:57.367 回答