ios - TTTAttributedLabel didSelectLink 未在 swift 4.0 中调用

标签 ios swift tttattritubedlabel

我使用 TTTAttributedLabel,这是我的代码。当我单击链接变得金光闪闪时,但 attributeLabel(_ label: TTTAttributedLabel!, didSelectLinkWith url: URL!) 没有调用。任何人都可以帮助我。我都这样为标签设置了委托(delegate)。你能帮我一下吗?

 import TTTAttributedLabel
   class MainVC : UIViewController,TTTAttributedLabelDelegate{

 @IBOutlet weak var lblTerms: TTTAttributedLabel!

  func setupMultipleTapLabel() {
    let str = "By signing up, I agree to \(APPNAME_AND_VERSION_ABOUT.capitalized)'s Terms of Service, Privacy Policy, Guest Refund Policy, and Host Gurantee Terms." as NSString
    lblTerms.text = str as String
    lblTerms.delegate = self
    let range : NSRange = str.range(of: "Terms of Service")
    lblTerms.addLink(to: NSURL(string: "\(WebServerUrl)terms_of_service")! as URL?, with: range)
    let range1 : NSRange = str.range(of: "Privacy Policy")
    lblTerms.addLink(to: NSURL(string: "\(WebServerUrl)privacy_policy")! as URL?, with: range1)
    let range2 : NSRange = str.range(of: "Guest Refund Policy")
    lblTerms.addLink(to: NSURL(string: "\(WebServerUrl)guest_refund")! as URL?, with: range2)
    let range3 : NSRange = str.range(of: "Host Gurantee Terms")
    lblTerms.addLink(to: NSURL(string: "\(WebServerUrl)host_guarantee")! as URL?, with: range3)
  }
  func attributedLabel(_ label: TTTAttributedLabel!, didSelectLinkWith url: URL!) {
    print("url \(url)")
    UIApplication.shared.openURL(url)
   }
}

最佳答案

我明白了..它工作正常...我使用 tab guster。所以我去掉了风口,它工作正常。

关于ios - TTTAttributedLabel didSelectLink 未在 swift 4.0 中调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51999968/

相关文章:

ios - didSelectLinkWithURL 没有被 TTTAttributedLabel 调用

ios - Swift 应用程序在打开后退出,在 Xcode 中运行

file - NSData(文件内容 : "someexistingfile") returns nil in Playground

ios - 如何在 IOS 中以编程方式使 TTTAttributedLabel 居中对齐

ios - 使用 OpenFeint 挑战系统随机接受挑战?

ios - 有没有办法在 iOS 中使用 Call Directory Extension 阻止 No Caller ID?

ios - 使用 SpriteKit 呈现插页式广告会重新启动整个场景

ios - TeamCity 8 xcode 5 代理代码签名错误

ios - 根据内容动态调整 UITextView 的高度?

ios - TTTAttributedLabel 链接检测无法使用 Storyboard