如何根据按下的按钮取消隐藏标记的详细信息公开按钮

时间:2015-04-07 23:39:47

标签: ios objective-c

在我的视图控制器中,我有6个按钮(IBAction buttonDown(标记为0 - 5)),以及它们相应的详细公开按钮(UIButton * disclosureButton(标记为0 - 5))。

我想知道默认情况下是否有隐藏所有细节公开按钮的方法,但如果按下标记为0的按钮,则会显示标记为0的详细公开按钮等。

以下是我目前在ViewController.m文件中的代码

    - (void)viewDidLoad{
    [super viewDidLoad];

    _stopSound.hidden = YES;

}

- (IBAction)stopSound:(UIButton *)sender {
    P11AppDelegate* app = [[UIApplication sharedApplication] delegate];
    [app.host stop];

    _stopSound.hidden = YES;

}

- (IBAction)buttonDown:(UIButton *)sender
{
    P11AppDelegate* app = [[UIApplication sharedApplication] delegate];
    [app.host start];
    [app playSound:sender.tag];

    _stopSound.hidden = NO;
}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{    
    UIButton* disclosureButton = sender;
    P11AppDelegate* app = [[UIApplication sharedApplication] delegate];
    app.editIndex = disclosureButton.tag;
}

@end

1 个答案:

答案 0 :(得分:0)

使用viewDidLoad中的以下代码解决:

   //hide info buttons
for (int i = 0; i < self.infoButtons.count; i++)
{
    UIButton* button = [self.infoButtons objectAtIndexedSubscript:i];
    button.hidden = YES;

}

按下按钮时:

//info button reappears when sound button is pressed
for (int i = 0; i < self.infoButtons.count; i++)
{
    UIButton* button = self.infoButtons[i];
    button.hidden = button.tag == sender.tag ? NO : YES;
}