警告:不兼容的 Objective-C 类型
警告:从不同的 Objective-C 类型传递“setFont:”的参数 1 时,不兼容的 Objective-C 类型“struct NSArray *”,预期为“struct UIFont *”
代码如下:
lblTemp.font = [UIFont fontNamesForFamilyName:@"Arial"]; // Warning comes here
lblTemp.font = [UIFont fontWithName:@"Arial-BoldMT" size:13];
[cell.contentView addSubview:lblTemp];
[lblTemp release];
请给出一些解决建议。
Warning: incompatible Objective-C types 'struct NSArray *', expected 'struct UIFont *' when passing argument 1 of 'setFont:' from distinct Objective-C type
Code Like:
lblTemp.font = [UIFont fontNamesForFamilyName:@"Arial"]; // Warning comes here
lblTemp.font = [UIFont fontWithName:@"Arial-BoldMT" size:13];
[cell.contentView addSubview:lblTemp];
[lblTemp release];
Please give some suggestion to solve to it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
-fontNamesForFamilyName:
返回字体名称数组,而不是UIFont
。您需要将此数组中的一个字符串传递给 +[UIFont fontWithName:size:] 以获取UIFont
对象(就像您在下一行中所做的那样) )。-fontNamesForFamilyName:
returns an array of font names, not aUIFont
. You'll want to pass one of the strings in this array to+[UIFont fontWithName:size:]
to get aUIFont
object back (as you do in the next line).does not return the Arial font, it returns the array of font names for the Arial font family. Check the manual here
does not return the Arial font, it returns the array of font names for the Arial font family. Check the manual here