【发布时间】:2015-10-10 03:23:39
【问题描述】:
当点击 UIlabel 时,我正在尝试使用所选号码打开 iPhone 通话屏幕,UIlabel 是 swift 中的超链接。
一个空白屏幕出现 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)
函数标签按下
func labelPressed() {
let url:NSURL = NSURL(string: "tel://08028542105")!
UIApplication.sharedApplication().openURL(url)
}
我的代码有什么问题或缺失。 我尝试在我的 iPhone 设备上运行。
【问题讨论】: