下面是我正在使用的一些代码。
我想要/期望的:
- 图像淡入;声音播放;延迟; 图像淡出。
发生什么了
- 延迟,声音播放,图像淡入然后立即淡出
非常感谢任何帮助。
视图控制器.m
[self fadein];
NSString *tempFN;
SystemSoundID soundID;
tempFN = [[NSString alloc] initWithFormat:@"%@.caf",
[myGlobals.gTitleArray objectAtIndex:myGlobals.gQuoteCountForLoop]];
NSString *soundFilePath = [NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], tempFN];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty (kAudioSessionProperty_AudioCategory,
sizeof (sessionCategory),
&sessionCategory);
AudioServicesCreateSystemSoundID((__bridge CFURLRef)soundFileURL, &soundID);
AudioServicesPlaySystemSound(soundID);
// Now fade-out the image after a few seconds delay
sleep(3);
[self fadeout];
-(IBAction)fadein
{
[UIImageView beginAnimations:NULL context:nil];
[UIImageView setAnimationDuration:2];
[faceImage setAlpha:0.3];
[UIImageView commitAnimations];
}
-(IBAction)fadeout
{
[UIImageView beginAnimations:NULL context:nil];
[UIImageView setAnimationDuration:1];
[faceImage setAlpha:0];
[UIImageView commitAnimations];
}