gpt4 book ai didi

ios - 在 swift 中单击 UILabel 时出现空白屏幕

转载 作者:行者123 更新时间:2023-11-30 14:00:33 26 4
gpt4 key购买 nike

当单击 UIlabel(Swift 中的超链接)时,我尝试打开包含所选号码的 iPhone 通话屏幕。

空白屏幕出现 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 设备上运行。

最佳答案

方便快速使用

let url:NSURL = NSURL(string: "telprompt:08028542105")!

而不是

let url:NSURL = NSURL(string: "tel://08028542105")!

关于ios - 在 swift 中单击 UILabel 时出现空白屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33049911/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com