未提供麦克风访问提示

时间:2015-08-11 19:41:20

标签: ios swift avaudiosession

在我的录音应用程序中,我试图让用户访问麦克风。但是,我一直得到.NotDetermined案例,没有提示。文档说明Not Determined案例会提示用户,但情况似乎并非如此。

@IBAction func recordTapped(recordButton: UIButton!){

    let microPhoneStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeAudio)

    switch microPhoneStatus {
    case .Authorized:
        // Has access
        println("access")
        vibrate()

        recordNow()

    case .Denied:
        // No access granted
        println("denied")


    case .Restricted:
        // Microphone disabled in settings
        println("mic disabled in settings")


    case .NotDetermined:
        // Didn't request access yet
        AVCaptureDevice.requestAccessForMediaType(AVMediaTypeAudio, completionHandler: nil)
        println("Not determined")
    }



}

0 个答案:

没有答案