【问题标题】:How Do i maintain my app in running state in background我如何在后台保持我的应用程序处于运行状态
【发布时间】:2014-02-04 05:51:02
【问题描述】:

我的应用程序没有从当前状态开始,如果不关闭我的应用程序,我将进入后台。我只是最小化我的应用程序而不是关闭我的应用程序。如果再次启动我的应用程序,它将从启动画面开始。

我想从我最小化我的应用程序的当前状态启动我的应用程序。

我的问题是:

我需要在应用委托类中做些什么,这是我的工作:

-(void) applicationDidEnterBackground:(UIApplication*)application {
    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"SplashLoadCheck"];
    [[NSUserDefaults standardUserDefaults]synchronize];     
    if( [navController_ visibleViewController] == director_ )       
         [director_ stopAnimation]; 
}

-(void) applicationWillEnterForeground:(UIApplication*)application 
{   
     if( [navController_ visibleViewController] == director_ )      
        [director_ startAnimation]; 
}

- (void)applicationWillTerminate:(UIApplication *)application {

    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"SplashLoadCheck"];
    [[NSUserDefaults standardUserDefaults]synchronize];     CC_DIRECTOR_END(); 
}

【问题讨论】:

    标签: ios


    【解决方案1】:

    您可以设置以下plist 标志。

    "Application Does Not Run in Background" = NO.
    

    这也将允许应用程序在后台运行。

    【讨论】:

    • 应用程序不在后台运行是关键吗?
    【解决方案2】:

    为了在后台运行您的应用,您应该启用应用所需的后台模式。这取决于您拥有的应用程序类型。否则苹果将拒绝该应用程序。还有一件事,即使您没有打开后台模式,应用程序也不会立即终止。操作系统会将您的应用程序置于空闲状态并在需要时自动终止。在此终止发生之前,如果您再次启动应用程序,应用程序将回到您在进入后台之前离开它的相同状态。

    这里是可用的背景模式列表

    【讨论】:

    • 我必须这样做
    • 在 Xcode 中选择您的应用目标。检查功能部分。启用此功能将为 info.plist 添加一个键
    • 项目和目标中不可用的背景模式也可以告诉我它在哪里可用
    • 是的 anil 你能告诉我我在哪里设置这个背景模式
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多