使用界面生成器设置UILabel的字体出来Helvetica [英] Setting font of UILabel with Interface Builder comes out Helvetica

查看:183
本文介绍了使用界面生成器设置UILabel的字体出来Helvetica的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Interface Builder为UILabels和UITextViews设置字体时遇到问题。
我试图设置字体吉尔三。
如果我以编程方式设置,它可以正常工作,如下所示:

  myLabel.font = [UIFont fontWithName:@鳃Sans大小:24.0]; 

但是,如果我尝试使用Interface Builder进行设置, iPhone SDK:界面生成器标签字体,只显示何时编辑标签,但是Gill Sans应该可以在iPad上使用(而且,如果我通过代码设置它,它就可以工作)。如果我运行它并执行此操作:

  NSLog(@%@,myLabel.font.fontName); 

打印出Helvetica。

通常我不会介意以编程方式设置,但问题是这个特定的类在不同的地方使用不同的nib文件提供不同的布局,所以我不能硬编码总是使用相同的字体系列。并且每次出现时都进行子类化将是一个巨大的痛苦,特别是因为我想让设计人员随时随地通过界面构建​​器创建和更改所有的布局,并且如果他们必须告诉我每次他们想要什么字体,可以硬编码每一个特定的情况下,这将是非常尴尬的。



有没有人遇到过这个问题?
也许Interface Builder限制了我使用iPhone字体,即使xib文件的目标已经设置到了iPad,但是我怎么说服我将目标锁定在iPad上呢?



在此先感谢,
filipe

解决方案

好吧,显然这已经被报告为一个bug与IB 3.2.3:

https://devforums.apple.com / message / 236134#236134

这家伙说它曾经在3.2.2上工作,所以我会看看我是否可以降级,或者我只是等待苹果的修复。


I'm having a problem setting the font for UILabels and UITextViews with Interface Builder. I'm trying to set the font to Gill Sans. If I set it programmatically it works fine, like this:

    myLabel.font = [UIFont fontWithName:@"Gill Sans" size:24.0];

But if I try setting it with Interface Builder, I get the same behaviour described in this question here iPhone SDK: Interface Builder label font, only shows when editing label, but the Gill Sans is supposedly available on the iPad (and it is, since it works if I set it by code). And if I run it and do this:

    NSLog(@"%@", myLabel.font.fontName);

it prints out "Helvetica".

Usually I wouldn't mind setting it programmatically, but the problem is that this particular class is used in several different places with different nib files to provide different layouts, so I can't have it hardcoded to always use the same font family. And subclassing it for each time it appears would be a huge pain, specially because I want to enable designers to create and change all the layout with interface builder whenever they want, and if they have to tell me what font they want every time so I can hardcode every particular case, that would be very awkward.

Has anyone experienced this problem before? Maybe Interface Builder is limiting me to use the iPhone fonts even though the xib file's target is already set to iPad, but how do I convince it that I'm targeting the iPad?

Thanks in advance, filipe

解决方案

Ok, apparently this has been reported as a bug with IB 3.2.3:
https://devforums.apple.com/message/236134#236134
This guy says it used to work on 3.2.2, so I'll see if I can downgrade, or I'll just wait for a fix from Apple.

这篇关于使用界面生成器设置UILabel的字体出来Helvetica的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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