简体   繁体   English

FontAwesome图标仅在释放模式下崩溃

[英]FontAwesome icon crash only when release mode

When my project in debug mode ,everything work fine. 当我的项目处于调试模式时,一切正常。 But when I change to release mode, my app crash at 但是当我更改为发布模式时,我的应用崩溃

[_menuButton setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:kFontAwesomeFamilyName size:30.0],
                                     NSForegroundColorAttributeName:[UIColor whiteColor]
                                     } forState:UIControlStateNormal];

the error message is 错误消息是

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]' *由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序,原因:“ * -[__ NSPlaceholderDictionary initWithObjects:forKeys:count:]:尝试从对象[0]中插入零对象”

If I commented the code , it can run fine but all FontAwesome icon became question mark. 如果我注释了该代码,它可以正常运行,但是所有FontAwesome图标都变成了问号。

Any idea to fix it ? 有解决的办法吗? Please help , thanks a lot ! 请帮忙,非常感谢!

As you can see, the error message warns you something becomes nil while inserting, so you need to check which object is nil. 如您所见,错误消息警告您插入时某些东西变为nil,因此您需要检查哪个对象为nil。

There is a high possibility reason: 原因很可能是:

[UIFont fontWithName:kFontAwesomeFamilyName size:30.0]

In release mode, kFontAwesomeFamilyName cannot be recognized, or the font file is not bundled into your app, so fontWithName returns nil. 在发布模式下,无法识别kFontAwesomeFamilyName ,或者字体文件未捆绑到您的应用程序中,因此fontWithName返回nil。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM