【问题标题】:How to properly minimize an iOS sprite kit application?如何正确最小化 iOS sprite kit 应用程序?
【发布时间】:2013-11-11 00:51:44
【问题描述】:

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

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

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

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

【问题讨论】:

  • 更多关于异常的细节会有所帮助。
  • 这个可能重复吗? Sprite Kit 和播放声音导致应用终止:stackoverflow.com/questions/18976813/…
  • 我认为这可能是问题所在,因为该教程有音频实现。感谢那个链接,我不知道。我认为链接问题的措辞可能会更好一些,以便在实际问题标题中提到进入背景方面。
  • 我所描述的问题与 EXC_BAD_ACCESS 代码 0x1 上面的链接重复。我检查了一下,甚至苹果的“冒险”演示项目似乎在单击主页后重新启动。

标签: iphone ios7 sprite-kit


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2023-04-09
      • 2023-03-03
      • 2013-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-03
      • 1970-01-01
      • 2013-06-16
      相关资源
      最近更新 更多