Iphone 在使用AudioServicesAddSystemSoundCompletion时,尝试从声音回调函数隐藏按钮时出错
我试图使用声音回调函数在声音文件播放完毕后显示一个按钮Iphone 在使用AudioServicesAddSystemSoundCompletion时,尝试从声音回调函数隐藏按钮时出错,iphone,objective-c,Iphone,Objective C,我试图使用声音回调函数在声音文件播放完毕后显示一个按钮 //defining the callback AudioServicesAddSystemSoundCompletion (soundID, NULL, NULL, AudioPlaybackComplete, self.nextButton); 下面是回调函数: static void AudioPlaybackComplete(SystemSoundID ssID, void *clientData) { } 我已经将nextB
//defining the callback
AudioServicesAddSystemSoundCompletion (soundID, NULL, NULL, AudioPlaybackComplete, self.nextButton);
下面是回调函数:
static void AudioPlaybackComplete(SystemSoundID ssID, void *clientData)
{
}
我已经将nextButton定义为头文件中的出口,并正确引用了它。当[nextButton setHidden:YES]出现以下错误时代码>尝试执行:“错误:'nextButton'未声明(此函数首次使用)
”
我相信,因为这是一个静态函数,所以它在引用此文件中的实例变量时遇到问题。关于如何让这个方法不是静态的,或者让它正确地引用按钮,我有什么想法吗
谢谢啊,我想起来了。诀窍是将按钮传递给回调函数
//defining the callback
AudioServicesAddSystemSoundCompletion (soundID, NULL, NULL, AudioPlaybackComplete, self.nextButton);
然后是回调函数本身
static void AudioPlaybackComplete(SystemSoundID ssID, void *button)
{
NSLog(@"Show those darn buttons");
AudioServicesRemoveSystemSoundCompletion (ssID);
//show the buttons so you can switch to the next animal
[button setHidden:NO];
}
啊,我想出来了。诀窍是将按钮传递给回调函数
//defining the callback
AudioServicesAddSystemSoundCompletion (soundID, NULL, NULL, AudioPlaybackComplete, self.nextButton);
然后是回调函数本身
static void AudioPlaybackComplete(SystemSoundID ssID, void *button)
{
NSLog(@"Show those darn buttons");
AudioServicesRemoveSystemSoundCompletion (ssID);
//show the buttons so you can switch to the next animal
[button setHidden:NO];
}