【问题标题】:CCLayer Subclass randomly crashes when adding CCSprite添加 CCSprite 时 CCLayer 子类随机崩溃
【发布时间】:2013-01-21 22:17:34
【问题描述】:

出于某种原因,每当我在一个正在执行的块中调用我的 CCLayer 子类时,代码似乎会因 EXE_BAD_ACCESS 而崩溃。

[[DataModel sharedInstance] saveWithSuccess:^{
                CCAlertView *alertView = [[CCAlertView alloc] initWithMessage:@"Unsaved Changes" detail:@"You have unsaved changes, would you like to save?" andButtons:@[@"Save", @"Continue", @"Cancel"]];
                alertView.delegate = (id <CCAlertViewDelegate>)self;
                [self.controls addChild:alertView z:100 tag:kAlertViewTag];
            } failure:^{
                CCAlertView *alertView = [[CCAlertView alloc] initWithMessage:@"Save Failed" detail:nil andButtons:@[@"Okay"]];
                alertView.delegate = (id <CCAlertViewDelegate>)self;
                [self.controls addChild:alertView z:100 tag:kAlertViewTag];
}];

我不太确定我做错了什么,是不是把它扔掉了?我在其他地方的代码上使用了这行代码,它可以工作。

【问题讨论】:

    标签: iphone objective-c macos cocos2d-iphone


    【解决方案1】:

    啊,我意识到我需要使用

    添加视图
    [[NSOperationQueue mainQueue] addOperationWithBlock:^{}];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-21
      • 1970-01-01
      • 1970-01-01
      • 2014-10-17
      • 2013-08-23
      相关资源
      最近更新 更多