0

我有两个UIButtons。按下时我能够使它们突出显示。:

-(IBAction) button1Pressed:(id)sender {

    [self performSelector:@selector(highlightButton1:) withObject:sender afterDelay:0.0];
}

- (void)highlightButton1:(UIButton *)a { 
    [a setHighlighted:YES];
}

-(IBAction) button2Pressed:(id)sender {

    [self performSelector:@selector(highlightButton2:) withObject:sender afterDelay:0.0];
}

- (void)highlightButton2:(UIButton *)b { 
    [b setHighlighted:YES];
}

我想在突出显示另一个按钮时取消突出显示一个按钮。但我不能让它工作。

4

1 回答 1

2

If you really have your buttons defined as:

IBOutlet NSButton * mode1;
IBOutlet NSButton * mode2;

then you can do:

- (void)highlightButton1:(UIButton *)a { 
    [mode1 setHighlighted:YES];
    [mode2 setHighlited:NO];
}

- (void)highlightButton2:(UIButton *)b { 
    [mode1 setHighlighted:NO];
    [mode2 setHighlited:YES];
}

parameters a & b are ignored in this particular case...

于 2012-06-06T02:05:53.433 回答