I have created a row of numberButtons inside a view dynamically.I am getting button highlighted when clicking any number.If I am clicking more than 1 in that row ,all of the clicked buttons get highlighted.What to do for avoiding multiple highlation?
I have used the code as follows
-(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;
}
I’m assuming that you mean that every button you tap is highlighted without removing the previous highlight.
To only have one button highlighted at a time. Keep track of what button was highlighted and remove its highlight when tapping another button.