applicationWillResignActive被调用但不调用代码

时间:2014-08-10 10:24:26

标签: ios objective-c xcode methods appdelegate

当应用程序被打断时,我试图暂停我的游戏! (如Phonecalls,SMS等)

我在Game Viewcontroller(rush_gamemode)中创建了一个暂停菜单。

当我按下游戏中的暂停按钮时,一切正常。 如果我通过" applicationWillResignActive"来调用方法。在AppDelegate中它确实有用。

这是我的代码:

在rush_gamemode.h中

-(void)goIntoPause;

在rush_gamemode.m

-(void)goIntoPause
{
NSLog(@"RUSH goIntoPause was called!");
self.Button_Pause.hidden = YES;


//--------pause timer-------//

if (self.timerStart) {
    timerWasStarted = YES;
    self.oldTimeNumber = self.timeNumber;
    [self.timerStart invalidate];
    self.timerStart = nil;
}

//--------set up pause menu--------//
self.transparent_subview_background.alpha = 0;

self.Pause_Subview.hidden = NO;
self.Pause_Subview.backgroundColor = [UIColor clearColor];

[UIView beginAnimations:NULL context:NULL];
[UIView setAnimationDuration:.75];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[self.transparent_subview_background setAlpha:0.75];
[UIView commitAnimations];
}

在AppDelegate.h中

@class rush_gamemode;

@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
rush_gamemode* rush;
}
在AppDelegate.m中的

我导入了&#34; rush_gamemode.h&#34;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
rush = [[rush_gamemode alloc] init];
return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
[rush goIntoPause];   
}

因此,当我启动应用程序,然后按HomeButton(例如)或拨打电话时,控制台显示NSLog(&#34; RUSH goIntoPause被调用!&#34;)但不做别的......

我在这里做错了什么?

欢呼,尼克拉斯

0 个答案:

没有答案