【问题标题】:– drawInRect:withAttributes: crashes when setting UIFont– drawInRect:withAttributes: 设置 UIFont 时崩溃
【发布时间】:2014-05-19 04:07:26
【问题描述】:

我有这个代码:

   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]: 无法识别的选择器发送到实例 0xcb77be0

* 由于未捕获的异常 'NSInvalidArgumentException' 导致应用程序终止,原因:'-[__NSDictionaryI font]: 无法识别的选择器发送到实例 0xcb77be0'

如果我使用已弃用的,它可以正常工作

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

我做错了什么?

【问题讨论】:

    标签: ios nsstring


    【解决方案1】:

    原因是您将应用部署在不支持方法 drawInRect:withAttributes: 的旧 iOS 版本 (

    【讨论】:

      猜你喜欢
      • 2011-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-08
      • 2019-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多