使用applicationDidBecomeActive使应用程序滞后和缓慢唤醒它 [英] Using applicationDidBecomeActive makes app lag and slow after awakening it

查看:1119
本文介绍了使用applicationDidBecomeActive使应用程序滞后和缓慢唤醒它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:这只会发生在我使用cocos2d和spritebuilder。

NOTE: This only happens when I use cocos2d and spritebuilder. I tried the same exact code with just a single view app which worked fine.

当使用applicationDidBecomeActive发送NSLog时,应用程序变得滞后,并在重新打开时变慢。这是一个非常简单的应用程序,所以它不必与密集的图形或进程。

When using applicationDidBecomeActive to send an NSLog, the app becomes laggy and slow upon being reopened. This is an extremely simple app so it does not have to do with intensive graphics or processes.

MainScene.m

MainScene.m

#import "MainScene.h"

@implementation MainScene

int score;

-(void)digButton {
    score++;
    scoreLabel.string = [NSString stringWithFormat:@"%i", score];
}
@end

那么这是appdelegate中的方法。 p>

then this is the method in appdelegate.

-(void)applicationDidBecomeActive:(UIApplication *)application
{
    NSLog(@"hi");
}

此方法不能与cocos2d正常工作吗?

Does this method not work correctly with cocos2d or something?

推荐答案

确保调用超级实现o CCAppDelegate方法:

Make sure to call the super implementation o CCAppDelegate methods:

-(void)applicationDidBecomeActive:(UIApplication *)application
{
    NSLog(@"hi");
    [super applicationDidBecomeActive:application];
}


$ b <

Without that the default CCAppDelegate implementation won't run, which resumes the director:

-(void) applicationDidBecomeActive:(UIApplication *)application
{
    [[CCDirector sharedDirector] setNextDeltaTimeZero:YES];
    if( [navController_ visibleViewController] == [CCDirector sharedDirector] )
        [[CCDirector sharedDirector] resume];
}

这篇关于使用applicationDidBecomeActive使应用程序滞后和缓慢唤醒它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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