2016-01-14 90 views
0

在我的tvOS遊戲中,當我觸發一個系統彈出窗口(即按住「HOME」顯示「SLEEP/CANCEL」彈出窗口或應用內購買確認提示),不調用applicationWillResignActive/applicationDidBecomeActive函數。tvOS: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 
+0

嗨,歡迎來到SO。請添加代碼的重要部分。請閱讀[如何提問](http://stackoverflow.com/help/how-to-ask)和[mcve](http://stackoverflow.com/help/mcve)以獲取更好的收到問題。 – davejal

回答

0

原來它的錯誤與tvOS 9.0。 更新到最新版本的XCode和設備固件 - 問題消失