Вопрос

I have 2 NSButtons, Both IBActions. When I click one of the buttons, I want the other button to be hidden. I can make them Hide themselves, but I can't figure out how to hide the other one. My actual implementation for this is to have a 'start' button, that is hidden until the user is finished doing some tasks, then shows up again with the other objects being hidden.

Thanks for your help!

@interface Label : NSObject 
{
    IBOutlet NSTextField *myTextField;
}

-(IBAction)btnTest1:(id)sender;
-(IBAction)btnTest2:(id)sender;

-(IBAction)btnTest1:(id)sender
{
    myTextField.stringValue = @"You selected the 1st Button";

    NSButton *tempButton = sender;
    [tempButton setHidden:YES];
}

-(IBAction)btnTest2:(id)sender
{
    myTextField.stringValue = @"You selected the 2nd Button";

    NSButton *tempButton = sender;
    [tempButton setHidden:YES];
}
Это было полезно?

Решение

@interface Label : NSObject 
{
    IBOutlet NSTextField *myTextField;
    IBOutlet NSButton *btn1;
    IBOutlet NSButton *btn2;
} 

in method : [btn1 setHidden: YES] for btn2 the same.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top