我会尽可能清楚地解释我的问题。我有一架钢琴,你可以弹奏并录制你所做的歌曲,你弹奏的钢琴的每个按钮,这个按钮都会突出显示。问题是我有另一个按钮来播放我录制的歌曲,但我想要的是突出显示正在发声的钢琴的每个按钮。这是我编写的函数的一部分:
- (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);
}
您可以看到,在每个音符中,我都会突出显示该音符的按钮,但我遇到的问题是该按钮仅在功能结束后才突出显示,因此一旦旋律完成,我的所有音符都会突出显示。我希望有一个人可以帮助我。