【问题标题】:How to Unhide tagged detail disclosure button depending on which button was pressed如何根据按下的按钮取消隐藏标记的详细信息披露按钮
【发布时间】:2015-04-07 23:39:47
【问题描述】:

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

【问题讨论】:

    标签: ios objective-c


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-14
      • 2011-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多