1
如何将存储电话号码的变量分配给按钮以调用该号码?使用Swift拨打电话号码
我正在使用Swift。这里是我的代码:
func base() {
var myBase = sharedDefaults!.objectForKey("base") as? String
if myBase != nil {
if myBase == "FRA" {
titleLabel.text = "FRANKFURT"
adressLabel.text = "some adress"
var phone = "+49123456 69 69804616"
coorPhone.setTitle("Duty Desk : \(phone)", forState: .Normal)
logoImage.image = UIImage(named: "flaggermany")
} else if myBase == "LHR" {
titleLabel.text = "LONDON"
adressLabel.text = "some adress"
var phone = "+44123456"
coorPhone.setTitle("Duty Desk : \(phone)", forState: .Normal)
logoImage.image = UIImage(named: "flaguk")
}
}
@IBAction func phoneButtonPressed(sender: AnyObject) {
// let telUrlString = "tel://" + phone
// UIApplication.sharedApplication().openURL(NSURL(string: "\ (telUrlString)")!)
}
非常感谢你的工作 – birkyboy