当您按下主页按钮时,SpriteKit应该清理并暂停所有计时器.
但是,我们发现如果您在显示活动SKView时单击主页按钮,则应用程序崩溃.即使该视图已被用户暂停,也会发生这种情况.
奇怪的是,如果你双击主页按钮并转到多任务视图,一切正常.
跟进注意:模拟器在两种情况下都能完美运行,不会发生崩溃
有没有人用SpriteKit看到这个问题?
你找到了原因/解决方案吗?
解决方法
@H_403_15@ 我有同样的问题,我解决了它在应用程序移动到后台之前手动暂停ViewController中的根SKView:- (void)viewDidLoad { [super viewDidLoad]; // Configure the view (already setup as SKView via storyboard) SKView * skView = (SKView *)self.view; // Create and configure the scene. SKScene *scene = [Menu sceneWithSize:CGSizeMake(skView.bounds.size.height,skView.bounds.size.width)]; scene.scaleMode = SKSceneScaleModeAspectFill; // Present the scene. [skView presentScene:scene]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillEnterBackground) name:UIApplicationWillResignActiveNotification object:NULL]; } - (void)appWillEnterBackground { SKView *skView = (SKView *)self.view; skView.paused = YES; [[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillEnterForeground) name:UIApplicationWillEnterForegroundNotification object:NULL]; } - (void)appWillEnterForeground { SKView * skView = (SKView *)self.view; skView.paused = NO; [[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillEnterBackground) name:UIApplicationWillResignActiveNotification object:NULL]; }