Iphone 应用程序中的许多字体文件导致.xib文件无法加载

Iphone 应用程序中的许多字体文件导致.xib文件无法加载,iphone,ios,Iphone,Ios,我的iphone应用程序中有600个字体文件,应用程序无法找到包含600个文件的.xib文件。如果我删除了600个文件,那么.xib文件就可以正常加载 我检查了应用程序中资源文件的数量限制,但没有限制。此外,文件的大小只有100MB,这是正常的。我不知道是什么问题。嗯,我有好消息和坏消息。坏消息是,你可能在iOS中遇到了一些软限制,因为苹果从来没有想到有人会在iPhone中使用这么多字体 好消息是,您可以直接从文件中加载CGFonts和CTFonts。糟糕的是,你必须用核心图形或核心文本来绘制,

我的iphone应用程序中有600个字体文件,应用程序无法找到包含600个文件的.xib文件。如果我删除了600个文件,那么.xib文件就可以正常加载


我检查了应用程序中资源文件的数量限制,但没有限制。此外,文件的大小只有100MB,这是正常的。我不知道是什么问题。

嗯,我有好消息和坏消息。坏消息是,你可能在iOS中遇到了一些软限制,因为苹果从来没有想到有人会在iPhone中使用这么多字体


好消息是,您可以直接从文件中加载CGFonts和CTFonts。糟糕的是,你必须用核心图形或核心文本来绘制,因为这些东西不是免费桥接的。

谢谢。这起作用了。但是,它需要创建新层来写入,而不是旧层

下面是完整的代码片段

#import <CoreText/CoreText.h>
#import <QuartzCore/QuartzCore.h>


CTFontRef ctfont =  [self newCustomFontWithName:@"cs" ofType:@"ttf" attributes:nil];
CATextLayer *  normalTextLayer_ = [[CATextLayer alloc] init];

normalTextLayer_.font = ctfont;
normalTextLayer_.string = @"alleluja";
normalTextLayer_.wrapped = YES;
normalTextLayer_.foregroundColor = [[UIColor purpleColor] CGColor];
normalTextLayer_.fontSize = 20.f;
normalTextLayer_.alignmentMode = kCAAlignmentCenter;
normalTextLayer_.frame = CGRectMake(0.f, 10.f, 320.f, 32.f);

[self.view.layer addSublayer:normalTextLayer_];    


CTFontRef cttFont =  [self newCustomFontWithName:@"cs" ofType:@"ttf" attributes:nil];
NSString *fontName = [(NSString *)CTFontCopyName(cttFont, kCTFontPostScriptNameKey) autorelease];

CGFloat fontSize = CTFontGetSize(cttFont);
NSLog(@"%f fontName = '%@'",fontSize,fontName);
UIFont *font = [UIFont fontWithName:fontName size:fontSize];
UITextView * xx = [[UITextView alloc] initWithFrame:CGRectMake(0, 100, 320, 200)];
xx.text = @"alleluja";
xx.font = font;



[self.view addSubview:xx];
#导入
#进口
CTFontRef ctfont=[self-newCustomFontWithName:@“cs”类型:@“ttf”属性:nil];
CATextLayer*normalTextLayer_u=[[CATextLayer alloc]init];
normalTextLayer_u2;.font=ctfont;
normalTextLayer.string=@“alleluja”;
normalTextLayer.wrapped=是;
normalTextLayer_u2;.foregroundColor=[[UIColor PUPPLECOLOR]CGColor];
normalTextLayer.fontSize=20.f;
normalTextLayer.alignmentMode=kCAAlignmentCenter;
normalTextLayer.frame=CGRectMake(0.f、10.f、320.f、32.f);
[self.view.layer addSublayer:normalTextLayer_u2;];
CTFontRef cttFont=[self-newCustomFontWithName:@“cs”类型:@“ttf”属性:nil];
NSString*fontName=[(NSString*)CTFontCopyName(cttFont,kCTFontPostScriptNameKey)自动删除];
CGFloat fontSize=CTFontGetSize(cttFont);
NSLog(@%f fontName='%@',fontSize,fontName);
UIFont*font=[UIFont fontWithName:fontName size:fontSize];
UITextView*xx=[[UITextView alloc]initWithFrame:CGRectMake(0,100320,200)];
xx.text=@“alleluja”;
xx.font=font;
[self.view addSubview:xx];
等等,你刚才说的是六百种字体的文件吗?看在上帝的份上,你会用600个字体文件做什么?还有那么多字体吗?