我試圖在swift中超鏈接的UIlabel上單擊打開帶有所選號碼的iPhone調用屏幕。在swift中單擊UILabel時會出現空白屏幕
一個空白屏幕出現1秒鐘後即可。不出現iPhone呼叫屏幕。不知道我的代碼中有什麼問題。在viewDidLoad中
代碼
let strPhone = "080 2854 2105"
let attributedPhoneStr = NSMutableAttributedString(string:strPhone, attributes:[NSLinkAttributeName: NSURL(string: "http://aerospace.honeywell.com")!])
lblPhoneContact.attributedText = attributedPhoneStr
lblPhoneContact.userInteractionEnabled = true
let gestureRecognizer = UITapGestureRecognizer(target: self, action: Selector("labelPressed"))
lblPhoneContact.addGestureRecognizer(gestureRecognizer)
功能labelPressed
func labelPressed() {
let url:NSURL = NSURL(string: "tel://08028542105")!
UIApplication.sharedApplication().openURL(url)
}
什麼是錯的還是我的代碼失蹤。 我試着在我的iPhone設備上運行。
不。使用「telprompt://」將調用請求調用,但是使用「tel://」將直接調用該號碼而不提示請求。 –