【发布时间】:2012-09-25 16:05:05
【问题描述】:
我在 xcode 4.5 和 sdk 6.0 中发现了另一个恼人的错误: 当我运行以下代码时:
UIColor *newcolor = [UIColor colorWithCIColor:[CIColor colorWithString:@"1 1 1 1"]];
[button setTitleColor:newcolor forState:UIControlStateNormal];
UILabel *lbl = selectedbutton.titleLabel;
它总是因错误而失败:
-[UICIColor colorSpaceName]: unrecognized selector sent to instance 0xa9864f0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICIColor colorSpaceName]: unrecognized selector sent to instance 0xa9864f0'
*** First throw call stack: [...]
libc++abi.dylib: terminate called throwing an exception
【问题讨论】:
-
当这种情况发生时查看堆栈上的符号会很有趣,以便找出导致该方法被调用的原因。如果您在字符串中明确使用浮点值是否有效:@"1.0 1.0 1.0 1.0"(或 @"1.0 1.0 1.0" 具有默认 alpha)?
-
不,也不起作用。同样的错误。我的真实值是浮点数,我在示例中放入整数来说明。我认为这与 de CIColor 颜色空间配置文件有关。
-
肯定会发生一些奇怪的事情,因为将用于创建颜色的代码粘贴到测试项目中并链接到 Core Image 框架不会给我任何错误。
标签: ios6 xcode4.5 unrecognized-selector