-1
    -(void)playSound: (NSString*)sound 

{
NSString *path = [[NSBundle mainBundle] pathForResource:sound ofType:@"mp3"];

    AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self; 
    [theAudio play];
    [AVAudioPlayer release];
}

すべてがまだ機能しますが、ラグを引き起こしている可能性のある厄介なエラーがあります。

4

1 に答える 1

1

プロトコルgameViewControllerに準拠していることを確認してください。AVAudioPlayerDelegate

@interface gameViewController : NSObject <AVAudioPlayerDelegate>
.
.
.
@end

それがあなたのクラスの名前だと仮定します。

于 2013-01-17T03:17:36.483 に答える