我在标签中显示减少倒数计时器从5到1。这工作正常。倒数计时器图像更改音频声音应该在iPhone中更改
当我的计时器启动并且它在标签中显示5时,它应该产生5的声音,当显示4时声音应该播放4。
我全部都是5 sounds from 5 to 1 in my resource file
。
建议我如何在定时器启动特定标签时设置此声音。
我在标签中显示减少倒数计时器从5到1。这工作正常。倒数计时器图像更改音频声音应该在iPhone中更改
当我的计时器启动并且它在标签中显示5时,它应该产生5的声音,当显示4时声音应该播放4。
我全部都是5 sounds from 5 to 1 in my resource file
。
建议我如何在定时器启动特定标签时设置此声音。
简单地让你的声音名称像这样5,4,3,2,1 .mp3或它的延伸。现在,当您在标签上同时书写时,请使用文字来制作声音文件名。并播放它。
在标签上书写文字后使用[NSString stringWithFormat:@"%@.mp3",lbl.text];
。
//将其作为实例变量保存在您的类中。
NSTimeInterval remainingTime = 5.0;
//定时器和每1秒触发定时器。
NSTimer *timer =[NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES];
[timer fire];
-(void) timerFireMethod:(NSTimer *) theTimer {
remainingTime = remainingTime - 1.0;
// Set the label with remaining time.
yourLabel.text = [NSString stringWithFormat:@"%lf", remainingTime];
// Play sound whose file name corresponds to the remaining time value...
if (remainingTime <= 0.0) {
[theTimer invalidate];
}
}
我越来越困惑于如何时,我的定时器改变 – Rani 2012-03-28 07:49:26
通过使用AVAudioPlayer播放声音播放声音,和你在哪里,在同一时间,在相同的方法改变勒贝尔的文本播放声音。 – Ishu 2012-03-28 07:52:06
使用此[的NSTimer scheduledTimerWithTimeInterval:<#(NSTimeInterval)#>目标:<#(id)#>选择器:<#(SEL)#> USERINFO:<#(id)#>重复:<#(BOOL)#>],这里通过选择和更新标签上的文本以及播放声音 – Ishu 2012-03-28 07:53:21