У меня есть UITextView
который отображает NSAttributedString
. Эта строка содержит слова, которые я хотел бы сделать так, чтобы их можно было использовать так, чтобы при их нажатии меня перезванивали, чтобы я мог выполнить действие. Я понимаю, что UITextView
может обнаружить нажатия на URL-адрес и перезвонить моему делегату, но это не URL-адреса.
Мне кажется, что с iOS 7 и мощью TextKit это теперь возможно, однако я не могу найти никаких примеров и не знаю, с чего начать.
Я понимаю, что теперь можно создавать пользовательские атрибуты в строке (хотя я еще не сделал этого), и, возможно, они будут полезны для обнаружения, если одно из волшебных слов было нажато? В любом случае, я до сих пор не знаю, как перехватить это нажатие и определить, по какому слову произошло нажатие.
Обратите внимание, что совместимость с iOS 6 не требуется.