ビュー内に numberButtons の行を動的に作成しました。任意の数字をクリックするとボタンが強調表示されます。その行で複数のボタンをクリックすると、クリックしたすべてのボタンが強調表示されます。複数の強調表示を避けるにはどうすればよいですか?
次のようにコードを使用しました
-(void)pressed:(id)sender{
UIButton *button = (UIButton *)sender;
if(!button.selected){
[NSTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(highlightButton:) userInfo:button repeats:NO];
} else {
[NSTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(unhighlightButton:) userInfo:button repeats:NO];
}
-(void)highlightButton:(id)sender{
UIButton *button = (UIButton *)[sender userInfo];
button.highlighted = YES;
button.selected = YES;
}
-(void)unhighlightButton:(id)sender{
UIButton *button = (UIButton *)[sender userInfo];
button.highlighted = NO;
button.selected = NO;
}