2013-11-11 1 views
1

Я пробовал это i OS Sprite Kit tutorial и создал подобное приложение. Тем не менее, я замечаю, что когда я нажимаю кнопку «домой», чтобы перейти на главный экран iOS, я получаю исключение плохого доступа в xCode. Когда я вернусь в приложение, оно начинается с самого начала.Как правильно минимизировать приложение набора спрайтов iOS?

Как правильно закрыть/свернуть приложение Sprite Kit, чтобы избежать этого исключения?

Я попробовал это в контроллере представления, представляя сцену, но не дозвонились:

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

Дополнительная информация о том, что такое исключение, поможет. – David

+0

Возможный дубликат [Нажатие кнопки дома вызывает EXC \ _BAD \ _ACCESS code = 1 в SpriteKit SKView] (http://stackoverflow.com/questions/19058096/home-button-press-causes-exc-bad-access-code- 1-in-spritekit-skview) – prototypical

+2

Возможный дубликат этого возможно? Sprite Kit и воспроизведение звука приводит к завершению работы приложения: http://stackoverflow.com/questions/18976813/sprite-kit-playing-sound-leads-to-app-termination – LearnCocos2D

ответ

0

я узнал, что есть Kobold Kit sprite engine built on top of Sprite Kit, после портирования моего проекта, что я могу минимизировать приложение и восстановить его с тем же материалом на экране!

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