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



在我的视图控制器中,我有6个按钮(IBAction buttonDown(标记为0-5)),以及它们相应的详细信息披露按钮(UIButton*disclosureButton(标记为2-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

在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;
}

相关内容

最新更新