- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有这个代码:
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/
我正在按照教程创建 CGSize,如下所示: CGSize size = [self.label.text sizeWithFont:(UIFont) forWidth:(CGFloat) line
正在尝试修复 iOS 应用程序中的一些警告并更改了此更新: [[self text] drawInRect:rect withFont:[UIFont systemFontOfSize:kFontSi
我能够绘制我的 NSString,但在绘制它们时我无法调整大小。我的 drawRect: 方法是: - (void)drawRect:(CGRect)rect { NSArray *objectArr
在我的应用程序的 iOS 5 版本中,我有: [self.text drawInRect: stringRect withFont: [UIFont fontWithName
在我的应用程序的 iOS 5 版本中,我有: [self.text drawInRect: stringRect withFont: [UIFont fontWithName
我在使用 Xcode 6.1 GM 时遇到了奇怪的问题。 let text: NSString = "A" let font = NSFont(name: "Helvetica Bold", size
我有这个代码: UIGraphicsBeginImageContextWithOptions(CGSizeMake(100, 100), NO, 0); UIFont* font = [U
当使用 -[NSString drawInRect:withAttributes:] 时,主要是在使用内置的 Helvetica Neue 以及其他字体时,字距调整非常糟糕。但是,当在文本编辑(使用
我正在更新适用于 iOS 7 的应用程序。其中一项更改是切换到新的 drawInRect:withAttributes 函数,而不是已弃用的 drawInRect:withFont...这在 iOS
开球Stackoverflow post ,这非常有帮助,我已经能够成功地将文本绘制到全屏图像上(我使用预先录制的短字符串标记图像,例如“垃圾箱”)。但是,文本没有出现在我想要的位置,它以用户点击的确
当我使用 drawInRect:withAttributes: 并传入带有 NSTextAlignmentCenter 的段落样式和 NSKernAttributeName 的非零值时,字符串没有正确
我正在使用 drawInRect : withAttributes 将文本添加到 iOS 7 中的 pdf。我需要在 CGRect 中垂直居中文本,或者至少我需要在 CGRect 边框和文本之间保持一
我正在开发我的应用程序的新版本并尝试替换已弃用的消息,但我无法通过这个。 我不明白为什么 drawInRect:withAttributes 不工作。代码在 drawInRect:withFont:l
我有一个 mov 文件,我正在通过在电影开头添加带有图像的轨道(使用 QTMovie 的 -addImage 方法)来修改该文件。当我压平这样的电影时(使用 QTMovie 的 -writeToFil
我正在尝试使用 QTKit 在 Cocoa 中创建电影。这部电影应该由我创建的一堆 NSImage 组成。我遇到了一些问题。总体问题是没有创建电影。我得到一个似乎是空的文件,只包含几百个字节,但没有电
我遇到了一些非常奇怪的事情:一个方法导致无法识别的选择器发送到实例,但根本没有NSLog()任何东西。 我制作了一个自定义的 NSControl 子类,我尝试在其中绘制我的自定义单元格,如下所示: -
此方法在 iOS 7.0 中已弃用: drawAtPoint:forWidth:withFont:fontSize:lineBreakMode:baselineAdjustment: 现在使用 dra
我正在尝试在我的应用程序中生成一个 pdf。为了绘制字符串,我使用 boundingRectWithSize 计算该字符串的边界矩形的大小,然后在该大小的矩形内绘制字符串。 该代码在 iOS 7.1
我是一名优秀的程序员,十分优秀!