I'm trying to make a "tagging window" much like the one used in Facebook where you type "@" and it make suggestions among your friends on which one to tag. I'd like this feature in my app, but I can't for the life of me figure out how to get the currently typed word in order to filter suggestions.
I use an UITextView
and I've been looking at this post https://stackoverflow.com/a/27380612/4148782
but I have issues translating this to Swift 3, and even so the comments suggests that this isn't solved anyway.
So the functionality I'm after is:
- User starts typing in a
UITextView
and if the word begins with a "@" I'd like to extract the word.
- I'd like to replace the word with a certain input as well. Let's say the user types @abc and I filter a suggestion which states "abcdef", then I want to be able to replace the @abc in the UITextView with "abcdef".
Note that I want the word currently getting typed and not the most recent typed word.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…