有类似的问题。并以这种方式修复它......
将我的自定义字体添加到我的资源组。然后通过下面给出的代码加载所有字体:
- (NSUInteger) loadFonts{
NSUInteger newFontCount = 0;
NSBundle *frameworkBundle = [NSBundle bundleWithIdentifier:@"com.apple.GraphicsServices"];
const char *frameworkPath = [[frameworkBundle executablePath] UTF8String];
if (frameworkPath) {
void *graphicsServices = dlopen(frameworkPath, RTLD_NOLOAD | RTLD_LAZY);
if (graphicsServices) {
BOOL (*GSFontAddFromFile)(const char *) = dlsym(graphicsServices, "GSFontAddFromFile");
if (GSFontAddFromFile)
for (NSString *fontFile in [[NSBundle mainBundle] pathsForResourcesOfType:@"ttf" inDirectory:nil])
newFontCount += GSFontAddFromFile([fontFile UTF8String]);
}
}
return newFontCount;}
- (id)initWithCoder:(NSCoder *)decoder {
//load the fonts
[self loadFonts];
if (self = [super initWithCoder: decoder]) {
[self setFont: [UIFont fontWithName: @"Quake" size: self.font.pointSize]];
}
return self;
}
希望它会奏效。