我正在尝试使用自定义字体制作菜单,但它似乎不起作用。这是代码:
- (id) init
{
if (self = [super init])
{
CGSize size = [[CCDirector sharedDirector] winSize];
[CCMenuItemFont setFontName:@"PC Senior Regular"];
[CCMenuItemFont setFontSize:18];
CCMenuItemFont *menu1 = [CCMenuItemFont itemFromString:@"Music ON" target:self selector:@selector(musicToggle)];
CCMenuItemFont *menu2 = [CCMenuItemFont itemFromString:@"Back" target:self selector:@selector(back)];
CCMenu *menu = [CCMenu menuWithItems:menu1, menu2, nil];
[menu setPosition:ccp(size.width / 2 , size.height / 2)];
[menu alignItemsVertically];
[self addChild:menu];
}
这是我的 info.plist 中的代码:
<key>UIAppFonts</key>
<array>
<string>PC Senior Regular.ttf</string>
<string>senior.ttf</string>
</array>
例外:
2012-07-27 05:42:35.369 Busterball[16089:10a03] In options
2012-07-27 05:42:35.371 Busterball[16089:10a03] -[__NSCFConstantString sizeWithZFont:]: unrecognized selector sent to instance 0xb0670
2012-07-27 05:42:35.372 Busterball[16089:10a03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString sizeWithZFont:]: unrecognized selector sent to instance 0xb0670'
我曾尝试使用senior.ttf,只是高级等。两种字体都被添加为项目的目标。我仔细检查了正确的类型案例。出了什么问题?