Stephen Fox Stephen Fox - 14 days ago 5
iOS Question

How to detect if a link, inside a UITextView has been clicked, Swift

I have implemented what I think is the function from UITextViewDelegate, which deals with URLs being tapped in a UITextView, however the functions now being called in my code.

This is the function I have used from the delegate.

func textView(textView: UITextView!, shouldInteractWithURL URL: NSURL!, inRange characterRange: NSRange) -> Bool {

println("Link Selected!")


However I have used breakpoints and the code isn't even being accessed at runtime?
Is this the correct function or is there an alternative?


You need to make sure that the class implementing the delegate protocol is set as the delegate for the UITextView.

self.textView.delegate = self