- (void)applicationWillResignActive:(UIApplication *)应用程序从未被调用 [英] - (void)applicationWillResignActive:(UIApplication *)application never gets called

查看:469
本文介绍了 - (void)applicationWillResignActive:(UIApplication *)应用程序从未被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想处理电话和待机状态。我添加了函数

   - (void)applicationWillResignActive:(UIApplication *)application 

   - (void)applicationDidBecomeActive: UIApplication *)应用程序

到我的UIApplicationDelegate。当退出待机状态时,applicationDidBecomeActive总是被调用。但是问题是applicationWillResignActive永远不会被调用。



我想知道是否有人遇到这个问题,以及是否有人找到原因。



EDIT



更多信息,我发现我的引擎的更新循环从applicationDidFinishLaunching运行,我错过了消息。我调用

  while(CFRunLoopRunInMode(kCFRunLoopDefaultMode,.002,FALSE)== kCFRunLoopRunHandledSource); 

捕获所有iphone消息,但它不会捕获resignActive消息, / p>

尝试为我的更新循环分支线程会导致奇怪的崩溃错误。任何人都有快速修复建议?

解决方案



当在iOS 4.0中点击主页按钮时,将调用以下代理方法

  - (void)applicationWillResignActive:(UIApplication *)application 
{
NSLog(@Application Did Resign Active);
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSLog(@Application Did Enter Background);
}

当您双击主页按钮并重新启动应用程序时,委托方法被调用。

   - (void)applicationWillEnterForeground:(UIApplication *)application 
{
NSLog (@应用程序将输入前景);
}



- (void)applicationDidBecomeActive:(UIApplication *)application
{
NSLog(@Application Did Being Active );
}


I'm trying to handle phone calls and standby and things of that nature. I added the function

- (void)applicationWillResignActive:(UIApplication *)application

and

- (void)applicationDidBecomeActive:(UIApplication *)application

to my UIApplicationDelegate. When coming out of standby, "applicationDidBecomeActive" always gets called. However the issue is "applicationWillResignActive" never gets called.

I was wondering if anyone has run into this issue and whether or not anyone found a reason.

EDIT

More info, I discovered that my engine's update loop that gets run from applicationDidFinishLaunching was causing me to miss the message. I call

while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, .002, FALSE) == kCFRunLoopRunHandledSource);

to catch all iphone messages but it doesn't seem to catch the resignActive message before becoming inactive.

Attempting to fork a thread for my update loop is causing weird crash bugs. Anyone have any quick fix suggestions?

解决方案

Its getting called in iOS 4.0 , when the Home button is hit.

The following delegate methods are called when the Home button is hit in iOS 4.0

- (void)applicationWillResignActive:(UIApplication *)application
{
  NSLog(@"Application Did Resign Active");
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
  NSLog(@"Application Did Enter Background");
}

And when you double tap the home button and again relaunch the App , the following delegate methods are called .

- (void)applicationWillEnterForeground:(UIApplication *)application
{
  NSLog(@"Application Will Enter Foreground");
}



- (void)applicationDidBecomeActive:(UIApplication *)application
{
  NSLog(@"Application Did Become Active");
}

这篇关于 - (void)applicationWillResignActive:(UIApplication *)应用程序从未被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆