UITextView font is nil

﹥>﹥吖頭↗ 提交于 2019-12-03 09:22:43

Try checking the "selectable" checkbox for this UITextView in Interface Builder. It's in the Attributes Inspector. Per @VahramDodoryan's comment below, you can then set selectable to false if you don't want to support selection.

I can't explain why this works, but it's probably a UIKit bug. I had an IBOutlet to a UITextView whose font property was nil, and it would not respond to any font or text-color changes in code until after its text property had been set. I arrived at this solution through trial-and-error.


If you're still encountering this issue on recent releases of iOS, consider opening a radar:

I tried changing every property and constraint , I had on my text view.

Including selectable as suggested above

In frustration in the end I deleted and re-added it and that was the unsatisfying fix.

You should try logging self.detailDescriptionLabel. The value might be null.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!