【发布时间】:2014-05-25 05:08:56
【问题描述】:
我正在将我的项目从使用 Cocos2D v2.1 转换为 V3.0。这是一个 UIKit 项目,添加了 Cocos2D 作为子项目,并且在几个视图控制器中延迟加载了 director。
我设法摆脱了所有编译器警告,它运行良好,似乎可以正常加载导向器,但随后崩溃如下:
-[NSConcreteMutableAttributedString hasAttribute:]: unrecognized selector sent to instance 0xc4f8ff0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteMutableAttributedString hasAttribute:]: unrecognized selector sent to instance 0xc4f8ff0'
*** First throw call stack:
(
0 CoreFoundation 0x0291a1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x026998e5 objc_exception_throw + 44
2 CoreFoundation 0x029b7243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0290a50b ___forwarding___ + 1019
4 CoreFoundation 0x0290a0ee _CF_forwarding_prep_0 + 14
5 0x0019d7d0 -[CCLabelTTF updateTexture] + 544
6 0x0019d546 -[CCLabelTTF visit] + 70
7 0x00181c86 -[CCNode visit] + 566
8 0x00181c86 -[CCNode visit] + 566
9 0x00202b9d -[CCDirectorIOS drawScene] + 381
10 0x00203fdc -[CCDirectorDisplayLink mainLoop:] + 92
断点在CCLabelTTF函数- (BOOL) updateTexture处停止
#ifdef __CC_PLATFORM_IOS
// Font color
if (![formattedAttributedString hasAttribute:NSForegroundColorAttributeName])
代码中只有一个CCLabelTTF,我是这样创建的:
self.scoreLabel = [CCLabelTTF labelWithString:NSLocalizedString(@"Score", @"") fontName:@"Marker Felt" fontSize:20 dimensions:CGSizeMake(100, 50)];
self.scoreLabel.horizontalAlignment = (CCTextAlignment)NSTextAlignmentRight;
scoreLabel.position = ccp(250,70);
[self addChild:scoreLabel z:1];
非常感谢任何帮助。我搜索了 Cocos2D 论坛和这里,找不到与此问题类似的任何内容。
【问题讨论】: