【发布时间】:2014-09-14 01:50:01
【问题描述】:
当我拨打CGFontCreateWithDataProvider在飞行模式时,我的应用程序冻结。不在飞行模式下,它工作正常。字体存储在设备上,不应发生网络访问。
调用该方法加载本地字体文件时:
[self registerIconFontWithURL:[[NSBundle mainBundle] URLForResource:@"FontAwesome" withExtension:@"otf"]];
以下方法中url的值为:
file:///var/mobile/Applications/48D3DA14-235B-4450-A081-7A6BA6116667/Blah.app/FontAwesome.otf
+ (void)registerIconFontWithURL:(NSURL *)url
{
NSAssert([[NSFileManager defaultManager] fileExistsAtPath:[url path]], @"Font file doesn't exist");
CGDataProviderRef fontDataProvider = CGDataProviderCreateWithURL((__bridge CFURLRef)url);
//******Freezes after the next line******
CGFontRef newFont = CGFontCreateWithDataProvider(fontDataProvider);
//******FROZEN******
CGDataProviderRelease(fontDataProvider);
CFErrorRef error;
CTFontManagerRegisterGraphicsFont(newFont, &error);
CGFontRelease(newFont);
}
iOS 7.1.x,iPhone 5。
我不知道为什么会发生这种情况,也无法找到任何帮助。有谁知道为什么会发生这种情况?
提前致谢!
【问题讨论】:
-
贴出相关代码
-
url的值是多少? -
@rmaddy 你看得太早了,它现在就在那里 =)
-
为什么不使用
CTFontManagerRegisterFontsForURL()?
标签: ios objective-c fonts freeze