AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)无法在AVAudioRecorder中工作

时间:2015-07-09 14:26:19

标签: ios

我想用AVAudioRecorder录制音频。

以下是代码:

-(void)recordButtonTouchDown {

    _textLabel.backgroundColor = [UIColor clearColor];
    _timer = [NSTimer scheduledTimerWithTimeInterval:0.05
                                              target:self
                                            selector:@selector(setVoiceImage)
                                            userInfo:nil
                                             repeats:YES];

}

-(void)setVoiceImage {

    currentCount += 0.05f;

    if (currentCount==50) {
       AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
    }
}

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)无效,为什么?

1 个答案:

答案 0 :(得分:0)

在下面的语句中可能是浮点舍入错误,因为测试浮点数是否相等确实需要Epsilon value

if (currentCount==50) {

请改为尝试:

if (currentCount >= 50.0f) {

确认:在if语句中添加断点。