当我尝试访问uibutton的titleLabel属性时出现奇怪的崩溃(xcode 4.5和IOS sdk 6.0) [英] Strange crash when I try to access to uibutton's titleLabel property (xcode 4.5 and IOS sdk 6.0)
本文介绍了当我尝试访问uibutton的titleLabel属性时出现奇怪的崩溃(xcode 4.5和IOS sdk 6.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我运行以下代码时,我发现xcode 4.5和sdk 6.0:
的另一个令人讨厌的错误:
I found another annoying bug with xcode 4.5 and sdk 6.0 : when I run the following code :
UIColor *newcolor = [UIColor colorWithCIColor:[CIColor colorWithString:@"1 1 1 1"]];
[button setTitleColor:newcolor forState:UIControlStateNormal];
UILabel *lbl = selectedbutton.titleLabel;
它总是失败并出现错误:
It always fail with the error :
-[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
推荐答案
我在使用colorWithCIColor之前找到了一个解决方法:
,我用它复制了它: / p>
I found a workaround : before using my colorWithCIColor, I made a copy of it with :
newcolor = [UIColor colorWithCGColor:newcolor.CGColor];
它解决了崩溃问题。
奇怪,无论如何
and it solves the crash. Strange, anyway
这篇关于当我尝试访问uibutton的titleLabel属性时出现奇怪的崩溃(xcode 4.5和IOS sdk 6.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文