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



我已经尝试了这个iOS精灵套件教程,并创建了一个类似的应用程序。但是,我注意到当我按下主页按钮转到iOS主屏幕时,我在xCode中出现错误的访问异常。当我回到应用程序时,它从头开始。

如何正确关闭/最小化雪碧套件应用以避免该异常?

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

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

我发现在精灵套件之上构建了 Kobold Kit 精灵引擎,在将我的项目移植到该引擎后,我可以最小化应用程序并在屏幕上使用相同的内容恢复它!

我相信

处理最小化应用程序的正确方法是通过以下方法在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.
}

最新更新