Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c OpenSAN字体在iOS模拟器中不工作_Objective C_Xcode_Fonts_Uilabel - Fatal编程技术网

Objective c OpenSAN字体在iOS模拟器中不工作

Objective c OpenSAN字体在iOS模拟器中不工作,objective-c,xcode,fonts,uilabel,Objective C,Xcode,Fonts,Uilabel,我想使用UILabel上的字体,但它没有显示在iOS模拟器中。显示的是默认的系统字体。我有: 1) 已将文件添加到project+并选择复制到应用程序文件夹 2) 添加到Info.plist 3) Xcode自动将所有字体添加到我的构建阶段文件夹中 4) 清理了这个项目,然后又建了一个 但它仍然没有出现!在我的代码中,我有: self.itemPrice = [[UILabel alloc] initWithFrame:CGRectMake(230.0, 30.0, 75.0, 30.0)];

我想使用
UILabel
上的字体,但它没有显示在iOS模拟器中。显示的是默认的系统字体。我有:

1) 已将文件添加到project+并选择复制到应用程序文件夹

2) 添加到Info.plist

3) Xcode自动将所有字体添加到我的构建阶段文件夹中

4) 清理了这个项目,然后又建了一个

但它仍然没有出现!在我的代码中,我有:

self.itemPrice = [[UILabel alloc] initWithFrame:CGRectMake(230.0, 30.0, 75.0, 30.0)];
        self.itemPrice.adjustsFontSizeToFitWidth = YES;
        self.itemPrice.font = [UIFont fontWithName:@"OpenSans-ExtraBold" size:13.0f];
        self.itemPrice.textAlignment = NSTextAlignmentCenter;
        self.itemPrice.text = [NSString stringWithFormat:@"%@", [Formatters formatPrice:self.item.price]];
        [self.slidingDetailScrollView addSubview:self.itemPrice];

有人知道是什么导致了这个奇怪的错误吗?

修复了它,这是因为这个小错误

self.itemPrice.font = [UIFont fontWithName:@"OpenSans-Extrabold" size:13.0f];
Extrabold
,而不是
Extrabold
。我按照建议打开了字体查看器,它显示在
PostScript Name


我现在使用了<代码>定义了< /代码>,并在我的应用程序中使用了一个字体字符串名称,以避免在代码中间出现用户错误和文字字符串。

请注意,<代码> fOntONTHON<代码>需要字体名称,而不是文件名。字体名称可以是“OpenSans ExtraBold”或类似名称,如果在“字体手册”应用程序中打开字体,则可以检查该字体。可能是键入了错误的字体名称,请打印所有配置的字体列表并检查名称两次。!lol我在尝试使用OpenSans SemiBold XD时遇到了完全相同的问题