Hi,
How do I prevent the Safari web browser from popping up as I already have Safari View Controller as a part of my app?
I am trying to open an link in a UITextView.
Thanks,
Raghavendra Rao
Hi,
How do I prevent the Safari web browser from popping up as I already have Safari View Controller as a part of my app?
I am trying to open an link in a UITextView.
Thanks,
Raghavendra Rao
When you want to use Safari View Controller, you need to explicitly instantiate one.
For example, if you want to open a link in your UITextView with Safari View Controller,
make your View Controller conform to UITextViewDelegate and implement a method like this:
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
let safariVC = SFSafariViewController(url: URL)
self.present(safariVC, animated: true, completion: nil)
return false
}
When you want to use Safari View Controller, you need to explicitly instantiate one.
For example, if you want to open a link in your UITextView with Safari View Controller,
make your View Controller conform to UITextViewDelegate and implement a method like this:
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
let safariVC = SFSafariViewController(url: URL)
self.present(safariVC, animated: true, completion: nil)
return false
}
Thanks.
'Return false' did the trick.