Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在使用AudioServicesAddSystemSoundCompletion时,尝试从声音回调函数隐藏按钮时出错_Iphone_Objective C - Fatal编程技术网

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];
    }