gpt4 book ai didi

ios - – drawInRect :withAttributes: crashes when setting UIFont

转载 作者:行者123 更新时间:2023-11-29 02:57:26 27 4
gpt4 key购买 nike

我有这个代码:

   UIGraphicsBeginImageContextWithOptions(CGSizeMake(100, 100), NO, 0);
UIFont* font = [UIFont systemFontOfSize:12.0f];
NSDictionary* attributes = @{ NSFontAttributeName: font };
[@"hello" drawInRect:CGRectMake(0, 0, 100, 100) withAttributes:attributes];
UIGraphicsEndImageContext();

它在 drawInRect 中崩溃

-[__NSDictionaryI font]: unrecognized selector sent to instance 0xcb77be0

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI font]: unrecognized selector sent to instance 0xcb77be0'

如果我使用 deprecated 就可以正常工作

[@"hello" drawInRect:CGRectMake(0, 0, 100, 100) withFont:font];

我做错了什么?

最佳答案

原因是您在不支持方法 drawInRect:withAttributes: 的旧 iOS 版本 (<7.0) 上部署了您的应用程序。此外,这就是为什么您可以毫无问题地运行已弃用的版本的原因。

关于ios - – drawInRect :withAttributes: crashes when setting UIFont,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23729567/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com