diff --git a/apple/iOS/platform.m b/apple/iOS/platform.m index 51e1ba70ff..d6dd2fef6e 100644 --- a/apple/iOS/platform.m +++ b/apple/iOS/platform.m @@ -243,16 +243,18 @@ void switch_to_ios() { } apple_gamecontroller_init(); + + apple_start_iteration(); } - (void)applicationDidBecomeActive:(UIApplication *)application { - apple_start_iteration(); + [self showGameView]; } - (void)applicationWillResignActive:(UIApplication *)application { - apple_stop_iteration(); + [self showPauseMenu: self]; } -(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation diff --git a/frontend/platform/platform_apple.c b/frontend/platform/platform_apple.c index 53ffcb36bf..21b7f08fd4 100644 --- a/frontend/platform/platform_apple.c +++ b/frontend/platform/platform_apple.c @@ -27,7 +27,7 @@ void apple_start_iteration(void); void apple_stop_iteration(void); -static CFRunLoopObserverRef iterate_observer; +static CFRunLoopObserverRef iterate_observer = NULL; static void do_iteration(void) { @@ -103,17 +103,22 @@ static void do_iteration(void) void apple_start_iteration(void) { - iterate_observer = CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting, - true, 0, (CFRunLoopObserverCallBack)do_iteration, 0); - CFRunLoopAddObserver(CFRunLoopGetMain(), iterate_observer, - kCFRunLoopCommonModes); + if (iterate_observer == NULL) { + iterate_observer = + CFRunLoopObserverCreate(0, kCFRunLoopBeforeWaiting, + true, 0, (CFRunLoopObserverCallBack)do_iteration, 0); + CFRunLoopAddObserver(CFRunLoopGetMain(), iterate_observer, + kCFRunLoopCommonModes); + } } void apple_stop_iteration(void) { - CFRunLoopObserverInvalidate(iterate_observer); - CFRelease(iterate_observer); - iterate_observer = 0; + if (iterate_observer != NULL) { + CFRunLoopObserverInvalidate(iterate_observer); + CFRelease(iterate_observer); + iterate_observer = NULL; + } } static void frontend_apple_get_environment_settings(int *argc, char *argv[],