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

问题描述 投票:0回答:1

有人吗?在开发基于VOIP的呼叫应用程序时,如何才能手动获得此选项?H

ios swift audio avfoundation voip
1个回答
0
投票

公共类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 {公共变量标题:字符串公共var键:字符串公共var图片:UIImage?public var isSelected:布尔=假公共var对象:可以吗?public init(_ title:String,_ key:String,_ image:UIImage ?, _ isSelected:Bool){self.title =标题self.key =键self.isSelected = isSelectedself.image =图片}}

class 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", image1, 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)
}

}

© www.soinside.com 2019 - 2024. All rights reserved.