2012-04-18 12 views
0

画面に触れるときにファイルを再生する必要があります。サウンドファイル "OnTouch"を再生するには

私は次のことを試してみましたが、それはうまくいきませんでした:

-(IBAction)play; 
{ 
    CFBundleRef mainBundle = CFBundleGetMainBundle(); 

    CFURLRef soundFileURLRef; 

    soundFileURLRef =CFBundleCopyResourceURL(mainBundle, 
    (CFStringRef) @"sound1", CFSTR ("wav"), NULL); 

    UInt32 soundID; 
    AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID); 
    AudioServicesPlaySystemSound(soundID); 
} 

答えて

1

あなたのウィンドウまたはメインビューにタッチハンドラを追加しましたか?

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    [super touchesBegan:touches withEvent:event]; 
    [yourObject play]; 
} 
関連する問題