如何正确地最小化iOS精灵套件应用程序?

时间:2013-11-11 00:51:45

标签: iphone ios7 sprite-kit

我已经尝试了这个OS Sprite Kit tutorial并创建了一个类似的应用。但是,我注意到当我按下主页按钮进入iOS主屏幕时,我在xCode中遇到了错误的访问异常。当我回到应用程序时,它从头开始。

如何正确关闭/最小化Sprite Kit应用以避免该异常?

我在呈现场景的视图控制器中尝试了这个,但它没有被调用:

-(void)viewWillDisappear:(BOOL)animated
{
    SKView * skView = (SKView *)self.view;
    skView.paused = YES;
    [super viewWillDisappear:animated];
}

2 个答案:

答案 0 :(得分:0)

我发现有Kobold Kit sprite engine built on top of Sprite Kit,在将项目移植到该项目之后,我可以最小化应用程序并使用屏幕上的相同内容恢复它!

答案 1 :(得分:-1)

我认为通过这些方法在AppDelegate中处理最小化应用程序的正确方法是:

- (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.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}