Hi guys,
I'm new to swift!
I would like to add a link to a text inside my View Controller, I found this code below.
When I run the App crash and is returning this error message:
"NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds"
I appreciate any help, thanks.
class ViewController: UIViewController, UITextViewDelegate {
@IBOutlet var textView: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
let attributedString = NSMutableAttributedString(string: "Link")
attributedString.addAttribute(.link, value: "https://www.apple.com", range: NSRange(location: 19, length: 55))
textView.attributedText = attributedString
}
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
UIApplication.shared.open(URL)
return false
}
}
Post
Replies
Boosts
Views
Activity
Hi
I'm new to swift and I have the following problem:
My project has a Tab bar menu that, when clicked, calls different Viewcontrollers, when I click on the menu, only the related title, and color that I determined appear, but the main content that I placed such as label, buttons, etc... does not appear.
I'm not using storyboard just doing everything by code inside each view controller.
What did I forget to do?