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