如何在SwiftUI中拨打电话。这是Swift和UIKit的示例代码:
guard let number = URL(string: "tel://" + "+1(222)333-44-55") else { return }
UIApplication.shared.open(number)
这里是Swift和UIKit版本的线程:
let numberString = "111-222-3334"
Button(action: {
let telephone = "tel://"
let formattedString = telephone + numberString
let url = URL(string: formattedString)!
UIApplication.shared.open(url)
}) {
Text(numberString)
}