点击标签时同时呼叫和短信选项

Call and sms option same time when taping a label

我正在尝试通过点击 phone 号码联系 phone 预订应用程序,如果将启动以打开通话应用程序或短信应用程序。

到目前为止我找到了这些选项:

UIApplication.shared.open(tlfURL, options: [:], completionHandler: nil)
UIApplication.shared.open(smsURL, options: [:], completionHandler: nil)

那些必须单独调用。 有没有办法通过点击标签一次来触发它们,呼叫和短信启动选项?

如果没有任何建议如何实施? UIActivityViewController ?

谢谢

我会用

UIAlertController

preferredStyle: .actionSheet

它将帮助您向用户呈现多个选项,让他们选择他们想做的事情。它看起来像这样:

    let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) // makes a new UIAlertController with no title or message

    // makes a new UIAlertAction to call on tap
    let callAction = UIAlertAction(title: "Call", style: .default) { _ in
        UIApplication.shared.open(tlfURL, options: [:], completionHandler: nil)
    }

    // makes a new UIAlertAction to sms on tap
    let smsAction = UIAlertAction(title: "SMS", style: .default) { _ in
        UIApplication.shared.open(smsURL, options: [:], completionHandler: nil)
    }

    // makes a new cancel action so the user can decide not to take any actions
    let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)

    // add the actions to the UIAlertController
    alertController.addAction(callAction)
    alertController.addAction(smsAction)
    alertController.addAction(cancelAction)

    // present the UIAlertController to the user so they can interact with it
    present(alertController, animated: true, completion: nil)