iOS App不会暂停

时间:2014-02-15 10:23:57

标签: ios iphone objective-c multitasking

我使用Sprite Kit创建了一个简单的iOS应用程序并将其放到我的iPhone上。该应用程序完全正常,但无论何时离开应用程序,然后返回到它,它不会恢复代码,而是重新启动它。我见过的大多数应用程序总是会回到原来的位置,如果你离开并重新进入,不需要从多任务栏中删除。也许暂停不是正确的词......我认为我应该在我的应用代表中做一些事情

    - (void)applicationWillResignActive:(UIApplication *)application
    {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    }
但是,我不知道如何使用它。

1 个答案:

答案 0 :(得分:0)

SpriteKit应该会自动暂停,但如果它没有将其添加到您的applicationWillResignActive:方法中:

SKView *view = (SKView*)self.window.rootViewController.view;
view.paused = YES;

并使用applicationDidBecomeActive:方法:

SKView *view = (SKView*)self.window.rootViewController.view;
view.paused = NO;