TTTAttributedLabel clickable link does not work in Swift 3

2.1k views Asked by At

I just upgraded to Swift 3. I created a TTTAttributedLabel with a clickable URL, unfortunately the delegate function does not work anymore. Anyone has similar problems?

    func attributedLabel(_ label: TTTAttributedLabel!, didSelectLinkWith url: URL!) {
}
2

There are 2 answers

0
Svitlana On BEST ANSWER
   extension YourViewController: TTTAttributedLabelDelegate {   
        func attributedLabel(_ label: TTTAttributedLabel!, didSelectLinkWith url: URL!) {
            UIApplication.shared.openURL(url)
        }
    }
1
Juan F. Caracciolo On

Did you remember to connect the delegate?

label.delegate = self

It is working for me