zoukankan      html  css  js  c++  java
  • 检测麦克风是否被开启? 没开启的 调用录音功能就提示一次

    if ([[AVAudioSession sharedInstance] respondsToSelector:@selector(requestRecordPermission:)]) {
    [[AVAudioSession sharedInstance] performSelector:@selector(requestRecordPermission:) withObject:^(BOOL granted) {
    if (granted) {
    // Microphone enabled code
    NSLog(@"Microphone is enabled..");
    }
    else {
    // Microphone disabled code
    NSLog(@"Microphone is disabled..");

    // We're in a background thread here, so jump to main thread to do UI work.
    dispatch_async(dispatch_get_main_queue(), ^{
    [[[[UIAlertView alloc] initWithTitle:@"Microphone Access Denied"
    message:@"This app requires access to your device's Microphone. Please enable Microphone access for this app in Settings / Privacy / Microphone"
    delegate:nil
    cancelButtonTitle:@"Dismiss"
    otherButtonTitles:nil] autorelease] show];
    });
    }
    }];
    }

  • 相关阅读:
    pinyin4j使用示例
    迭代器模式
    适配器模式
    策略模式
    装饰模式
    责任链模式
    命令模式
    中介者模式
    原型模式
    代理模式
  • 原文地址:https://www.cnblogs.com/Milo-CTO/p/4441196.html
Copyright © 2011-2022 走看看