swift4で、
動いていた
swift
1var comment: String = "コメントです" 2 3// 中略 4 5comment.draw(in: CGRect(x: 20, y: 100, width: rect.width / 2 - 20, height: rect.height - 200), withAttributes: [ 6 NSAttributedStringKey.foregroundColor: UIColor.black, 7 NSAttributedStringKey.font: UIFont.systemFont(ofSize: CGFloat(24)),] 8)
というコードを
swift
1var comment: String = "コメントです" 2 3// 中略 4 5comment.draw(in: CGRect(x: 20, y: 100, width: rect.width / 2 - 20, height: rect.height - 200), withAttributes: [ 6 NSAttributedStringKey.foregroundColor: UIColor.black, 7 NSAttributedStringKey.font: UIFont(name: "APJapanesefontT.ttf", size: 24)!] 8)
に変更したところ
fatal error: unexpectedly found nil while unwrapping an Optional value
というエラーが出るようになりました。
APJapanesefontT.ttf
はxcode
のTARGETS
のBuild Phases
のCopy Bundle Resources
に登録してあります。
原因と対処法を教えていただけますでしょうか?
追記 2017.10.6 22:01
こんな感じでいいのでしょうか?
だとすると、引き続き同じエラーが出てしまいます。
あと、xml
で見る方法がわからないので教えていただけますでしょうか?
追記 2017.10.7 6:59
xmlは見れました。
xml
1<key>UIAppFonts</key> 2 <array> 3 <string>APJapanesefontT.ttf</string> 4 </array>
となっていました。
.ttfのTarget Membershipにもチェックが入っています。
他に何か可能性はありますでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/10/06 13:24
2017/10/06 15:12
2017/10/06 21:59
2017/10/07 08:04
2017/10/07 08:12
2017/10/07 09:25