0
这是我的第一个问题。什么是UIButton backgroundImage键? iOS
我试图以编程方式更改UIButton
的背景图像,但有一个问题,我无法找到背景图像的关键。 明白了,这是我的代码:
[[self.view viewWithTag:69000+i] setValue:[UIImage imageNamed:[NSString stringWithFormat:@"%d-options.png", i+1]] forKey:@"backgroundImage"];
当这样执行,应用程序崩溃。给予此错误:
主题1:信号SIGTRAP在main.m文件
并在调试:(LLDB)
所以,如果我是正确的,并坠毁是由不正确引起的键(backgroundImage),引用背景图片的关键是什么?
非常感谢!
PD:我需要self.view viewWithTag完成这件事......
+1我想和backgroundImage所以我纠正它,它的工作!我不知道isKindOfClass方法。尽管按照我的方式改变背景图像的关键是什么?谢谢! – 2012-07-20 15:42:57
您无法通过将其分配给某个键来进行设置。这不是一本字典。您只能使用'setImage:forState:'和'setBackgroundImage:forState:'来设置'UIButton'的'image'和'backgroundImage'属性。 – 2012-07-20 15:56:43
@JustinPaulson了解。谢谢! – 2012-07-21 16:07:49