tvOS:在显示系统弹出窗口时未调用applicationWillResignActive / applicationDidBecomeActive

时间:2016-01-14 00:52:41

标签: tvos

在我的tvOS游戏中,当我触发系统弹出窗口(即按住“HOME”以显示“SLEEP / CANCEL”弹出窗口或应用程序内购买确认提示)时,不会调用applicationWillResignActive / applicationDidBecomeActive函数。

然而,当我暂停/恢复应用程序(即按住“MENU”按钮,多任务处理)时,它们被称为正确,但不会在显示这些弹出窗口时显示。

这对我来说是一个问题,因为我需要在这些弹出窗口显示时暂停游戏。

有什么我想念的吗?有没有办法确定这些弹出窗口何时在tvOS上显示?

  • 我查看了一些示例应用程序(DemoBots),它具有相同的行为。
  • 将代码作为iOS应用程序运行时,它可以正常工作
  • Apple TV App Store上的游戏正常运行。

代码是直截了当的

#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char * argv[]) 
{
    @autoreleasepool 
    {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    NSLog(@"applicationWillResignActive");
    // 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
{
    NSLog(@"applicationDidEnterBackground");
    // 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
{
    NSLog(@"applicationWillEnterForeground");
    // 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
{
    NSLog(@"applicationDidBecomeActive");
    // 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.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    NSLog(@"applicationWillTerminate");
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end

1 个答案:

答案 0 :(得分:0)

原来是tvOS 9.0的一个错误。 更新到最新版本的XCode和设备固件 - 问题就消失了