メモリゲームアプリケーションのボタンクリックで音楽ファイルを設定しました。
しばらくの間、音楽は適切に再生されますが、ボタンの数をクリックすると、アプリケーションから効果音が失われます。
-(void)setButtons_AsPerTheMatrixSelection
{
for ( i = 0 ; i < cv ; ++i )
{
for ( j = 0 ; j < ch ; ++j )
{
btnMatrix = [[[UIButton alloc] initWithFrame:CGRectMake(10+pw*j, 51+ph*i, width, height)] autorelease];
btnMatrix.tag = i*ch+j;
btnMatrix.userInteractionEnabled = TRUE;
bulImageStatus = FALSE;
[btnMatrix addTarget:self action:@selector(changeImage:) forControlEvents:UIControlEventTouchUpInside];
[btnMatrix setImage:imgDefaultBG forState:UIControlStateNormal];
[viewWithButtons addSubview:btnMatrix];
[arrButton addObject:btnMatrix];
}
}
}
-(void)changeImage:(id)sender
{
NSString *musicPath = [[NSBundle mainBundle] pathForResource:@"ding" ofType:@"mp3"];
if (musicPath)
TapSoud = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:musicPath] error:nil];
[TapSoud setDelegate:self];
[TapSoud prepareToPlay];
[TapSoud play];
}
これは何回押しても完全に機能しますが、特定のクリックの後、このボタンのクリックトーンを再生できません。
何が問題になる可能性があり、この問題をどのように解決できるか。
オーディオファイルを再生する他の方法はありますか?
適切な解決策を提案してください。
ありがとう。