Я пытаюсь реализовать какую-то функцию:
Мне нужен UITextView, который является адресом какого-то места, приводит пользователя к Apple Maps при нажатии на этот UITextView и отображает местоположение адрес в UITextView. Любые идеи о том, как я могу это сделать?
То, что я пытался сделать до сих пор:
import MapKit
@IBOutlet weak var firstAddressTapped: UITextView!
func viewDidLoad() {
let attributedString = NSMutableAttributedString(string: "The address of my place")
attributedString.addAttribute(.link, value: "http://maps.apple.com/?daddr=The+address+of+my+place", range: NSRange(location: 19, length: 55))
firstAddressTapped.attributedText = attributedString
}
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
UIApplication.shared.open(URL)
return false
}
Спасибо!