【问题标题】:iOS App is not suspendingiOS 应用程序未暂停
【发布时间】:2014-02-15 10:23:56
【问题描述】:

我使用 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.
    }

但是我不知道如何使用它。

【问题讨论】:

  • 这可能是一种可能性,但是当我在 iOS 模拟器中运行它时,它似乎完全可以挂起。我怎么知道它在暂停时是否崩溃?
  • 查看本教程以获取精灵套件。 link

标签: ios iphone objective-c multitasking


【解决方案1】:

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

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

在你的applicationDidBecomeActive: 方法中:

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

【讨论】:

    猜你喜欢
    • 2016-10-03
    • 2016-02-22
    • 2013-09-12
    • 1970-01-01
    • 2013-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多