我试图在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://”将直接调用该号码而不提示请求。 –