TTTAttributedLabel didSelectLink 未在 swift 4.0 中调用
TTTAttributedLabel didSelectLink is not calling in swift 4.0
我使用 TTTAttributedLabel,这是我的代码。当我点击 Link 变得闪闪发光时,但 attributedLabel(_ label: TTTAttributedLabel!, didSelectLinkWith url: URL!) 没有调用。任何人帮助我。我都为标签设置了代表。你能帮帮我吗
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。所以我移除了 guster,它工作正常。
我使用 TTTAttributedLabel,这是我的代码。当我点击 Link 变得闪闪发光时,但 attributedLabel(_ label: TTTAttributedLabel!, didSelectLinkWith url: URL!) 没有调用。任何人帮助我。我都为标签设置了代表。你能帮帮我吗
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。所以我移除了 guster,它工作正常。