ios - 获取音频选项并在内部切换它们以调用应用程序

标签 ios swift audio avfoundation voip

请问有人吗?我们如何在开发基于 VOIP 的调用应用程序时手动获取此选项? H

最佳答案

公共(public)类 AlertSheet:NSObject {

public static func showActionSheet(_ actions: [AlertSheetModel], _ title: String,comletion: @escaping (_ action: AlertSheetModel, _ status: Bool) -> Void,onViewCotroller:UIViewController) {

    var style = UIAlertController.Style.actionSheet
    if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad) {
        style = UIAlertController.Style.alert
    }

    let alert = UIAlertController(title: nil, message: nil, preferredStyle: style)
    for actionData in actions {
        let action = UIAlertAction(title: actionData.title
            , style: .default, handler: { (UIAlertAction) in
                comletion(actionData, true)
        })

        if let icon = actionData.image {
            action.setValue(icon, forKey: "image")
        }
        action.setValue(true, forKey: "checked")
        alert.addAction(action)
    }
    let cancel = UIAlertAction(title: "Cancel", style: UIAlertAction.Style.cancel, handler: { (UIAlertAction)in
    })

    alert.addAction(cancel)
    onViewCotroller.present(alert, animated: true, completion: nil)
}

打开类 AlertSheetModel { 公共(public)变量标题:字符串 公钥:字符串 公共(public)变量图像:UIImage? 公共(public)变量 isSelected: Bool = false 公共(public)变量对象:有吗? public init(_ title: String,_ key: String, _ image: UIImage?, _ isSelected: Bool) { self.title = 标题 self.key = 键 self.isSelected = isSelected self.image = 图片 }

类 testActionSheet:UIViewController {

// initialize the image for following icon
let image1: UIImage = UIImage.init()
let image2: UIImage = UIImage.init()
let image3: UIImage =  UIImage.init()

override func viewDidLoad() {
    super.viewDidLoad()
    self.showActionSheet()
}

private func showActionSheet() {
    let actionSheet1 = AlertSheetModel.init("iPhone", "iphone", image1, false)
    let actionSheet2 = AlertSheetModel.init("Speaker", "speaker", image2, false)
    let actionSheet3 = AlertSheetModel.init("Samsung Level U", "samsung", image3, true)

    AlertSheet.showActionSheet([actionSheet1,actionSheet2,actionSheet3], "", comletion:  { (sharedClick: AlertSheetModel, success) in

        if sharedClick.key == "iphone" {
           // handle the click action of iphone button
        }else if sharedClick.key == "speaker" {
            // handle the click action of speaker button
        } else if sharedClick.key == "samsung" {
            // handle the click action of samsung button
        }else {
        }
    }, onViewCotroller: self)
}

关于ios - 获取音频选项并在内部切换它们以调用应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58946849/

相关文章:

ios - 如何在 SwiftUI 中使用 SegmentedPickerStyle() 更改选取器的高度?

ios - 无法在 swift 2 中将 json 数组解析为 nsarray

arrays - Swift - 按日期和时间一次性对数组进行排序

javascript - 聊天系统中出现ping声

audio - 驱动直流偏置音频信号时避免扬声器爆裂

ios - 在循环中使用 dataWithContentsOfURL 内存泄漏

ios - MagicalRecord 2.3.0/3.0 在对象中保存对象

ios - IOS检测其他音乐是否暂停?

ios - 从 iOS 应用程序处理飞行模式开/关状态

iOS gestureRecognizer 未处理 subview