Reputation: 107
I am using a textView in the page Container view of PageController. Here is my Code -
class pageContentView: UIViewController,UITextViewDelegate {
@IBOutlet weak var lblDetailTextt: UILabel!
@IBOutlet weak var lblDetailHeading: UILabel!
@IBOutlet weak var txtvieww: UITextView!
var strHeadingText = String()
var strText = String()
var itemIndex: Int = 0
override func viewWillAppear(_ animated: Bool) {
txtvieww.delegate = self
}
override func viewDidLoad() {
super.viewDidLoad()
//lblDetailTextt.text = strText
lblDetailHeading.text = strHeadingText
//self.lblDetailTextt.attributedText = self.stringFromHtml(string: strText)
txtvieww.attributedText = self.stringFromHtml(string: strText)
// Do any additional setup after loading the view.
}
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
print("enabledd")
return true
}
But the Delegate method is not calling.Do anyone have any idea how to call it?
Upvotes: 0
Views: 65
Reputation: 111
Check your textview and make sure its properties has correct settings
"Links in text views are interactive only if the text view is selectable but noneditable. That is, if the value of the UITextViewselectable property is YES and the editable property is NO."
Try this:
txtvieww.isEditable = false
txtvieww.isSelectable = true
Upvotes: 2