scaledValueForValue:调用没有文本样式集的字体 [英] scaledValueForValue: called on a font that doesn't have a text style set

查看:102
本文介绍了scaledValueForValue:调用没有文本样式集的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Xcode 6预发行版(非测试版)和OS X 10.10 Yosemite beta 7上的模拟器。我正在尝试构建一个在xcode 6中开发的项目,但每当我打开某个视图控制器时应用程序崩溃。这个视图控制器字面上没有代码(它是一个空的,静态的,表视图控制器,有几个默认的单元格和标签)。

I am currently using the Xcode 6 pre release (not beta) and the simulator on OS X 10.10 Yosemite beta 7. I am trying to build a project developed in xcode 6, but the app crashes whenever I open a certain view controller. This view controller literally has no code in it (it is an empty, static, table view controller that has a couple of default cells and labels).

给出的错误是:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:  
'scaledValueForValue: called on a font that doesn't have a text style set'

就在我发出此断言失败之前:

And right before I am given this assertion failure:

*** Assertion failure in -[UICTFont _scaledValueForValue:],         
/SourceCache/UIFoundation_Sim/UIFoundation-371/UIFoundation/iOS/UIFont.m:496

我真的不知道发生了什么,我试过在VC中设置断点但是在调用viewDidLoad方法之后发生错误(因此在执行完所有代码之后)。

I seriously have no idea what is going on, I tried setting breakpoints in the VC but the error happens after the viewDidLoad method is called (and thus after all my code is executed).

任何想法?我项目中所有内容的字体都是'Baskerville',我试过更改它但不影响崩溃。

Any Ideas? The fonts for everything in my project is 'Baskerville' and I have tried changing that but it does not affect the crash.

哦,如果我使用Xcode,它可以正常工作5。

Oh, and it works fine if I use Xcode 5.

更新9/24 :所以我仍然无法解决这个问题。我尝试使用fontWithDescriptor方法,但它仍然崩溃。有趣的是,我有很多页面使用自定义字体,大多数工作正常,但有两个VC,当我去他们时立即崩溃...其中一个甚至没有任何自定义字体。我非常感谢您的所有反馈,但有没有人有任何其他想法/修复?我正在使用Xcode的正式版本,它仍然无效。

Update 9/24: So I am still unable to figure this out. I tried using the fontWithDescriptor method, but it still crashes. The funny thing is, I have plenty of pages that use custom fonts and most of them work fine, but there are two VCs that crash immediately when I go to them... one of them doesn't even have any custom fonts. I really appreciate all of your feedback, but does anyone have any other ideas/fixes? I am using the official release of Xcode and it still doesn't work.

推荐答案

此问题已在iOS 8.1中修复。

This problem has been fixed in iOS 8.1.

我没有花时间构建自定义页眉/页脚视图,我只是不将自定义字体应用于运行iOS 8.0的设备。大多数人可能已经更新到iOS 8.1。

Instead of spending time building a custom header/footer view, I just not apply the custom font to devices running iOS 8.0. Most people will probably have updated to iOS 8.1 anyway.

我使用以下代码:

NSOperatingSystemVersion iOS_8_1 = (NSOperatingSystemVersion){8, 1, 0};

if (![[NSProcessInfo processInfo] respondsToSelector:@selector(isOperatingSystemAtLeastVersion:)]
    || [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:iOS_8_1]) {
    header.textLabel.font = [UIFont fontWithName:@"Avenir-Medium" size:header.textLabel.font.pointSize];
}

如果设备运行的iOS版本低于8,则第一条语句为true (因为 isOperatingSystemAtLeastVersion:是在iOS 8.0中引入的)。如果设备运行iOS 8.1或更高版本,则第二个语句为真。因此,对于这两个语句,我们只排除运行iOS 8.0的设备。

The first statement is true if the device is running an iOS version lower than 8 (since isOperatingSystemAtLeastVersion: was introduced in iOS 8.0). The second statement is true if the device if running iOS 8.1 or later. With both statements we thus only exclude devices running iOS 8.0.

这篇关于scaledValueForValue:调用没有文本样式集的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆