【发布时间】:2015-06-19 16:39:33
【问题描述】:
遇到了麻烦。 我有一个 UIButton 我想作为开/关开关来告诉其他按钮运行一些代码。 基本上,如果 UIButton 为“开”,那么当点击屏幕上的所有其他按钮时,将随机更改视图的背景颜色。 感谢您的帮助!
这是我正在使用的想法。超级新的,不太明白。感谢您的帮助!
// Buttons Play Sounds
////////////////////////////////////////////////////////
- (IBAction)D1{
[self playD1];
}
- (IBAction)A2{
[self playA2];
}
- (IBAction)Bb3{
[self playBb3];
}
- (IBAction)D5{
[self playD5];
}
- (IBAction)G7{
[self playG7];
// Make array of the buttons?
- (IBAction)switchNotes:(UIButton *)sender {
sender.selected = !sender.selected;
if(sender.selected)
{
NSLog(@"Switch is ON");
for(UIButton *myButton in self.myButtonCollection) {
// What to do?
}
}
else
{
NSLog(@"Switch is OFF");
for(UIButton *myButton in self.myButtonCollection) {
// what to do?
}
}
【问题讨论】:
-
请发布您正在进行的实施。
-
按钮处于关闭位置时的行为应该是什么?
-
大家好,我在上面添加了代码。感谢您的帮助!
-
嗨 BeemerFan 在关闭位置,视图背景颜色保持原始黑色。当屏幕上的所有按钮都可以改变背景颜色时
标签: ios button switch-statement