I will try to explain my problem as clear as I can.
I have a piano that you can play and record the song what you do, and every button of the piano that you play, this button is highlighted. The problem is that I have another button to play the song that I have recorded, but what I want is to Highlight every button of the piano that is sounding.
Here is a part of the function I’ve coded:
- (IBAction)play:(id)sender
{
for(NSString *string in [Singleton sharedInstance].notesMusicals)
if([string isEqualToString:@"doMenor"]){
UIImage *buttonImage = [UIImage imageNamed:@"do-menor_ON.png"];
[doMenorButton setImage:buttonImage forState:UIControlStateNormal];
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle,(CFStringRef) @"Do_m", CFSTR ("mp3"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
//doMenorButton.highlighted = YES;
sleep(1);
}
else if([string isEqualToString:@"Re"]){
UIImage *buttonImage = [UIImage imageNamed:@"do-menor_OFF.png"];
[doMenorButton setImage:buttonImage forState:UIControlStateNormal];
UIImage *buttonImage1 = [UIImage imageNamed:@"re_ON.png"];
[reButton setImage:buttonImage1 forState:UIControlStateNormal];
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle,(CFStringRef) @"Re", CFSTR ("mp3"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
sleep(1);
}
You can see that in every note, I highlight the button of that note, but the problem I have is that the button is only highlighted once the function ends, so all my notes will be highlighted once the melody has finished.
I hope someone can help me.
Try to call your highlightning code in a separate thread with
For example:
Please excuse if there are any typos in the code. I modified it right here in the editor.
You’ll need to modify me example in order to deactive other highlighted buttons but that should be no problem