Reputation: 2597
I want to implement a UITextView with a custom source for autocorrect values. What I exactly want to do, is to provide the user a autocorrect value for hash tags, so as soon as the user enters "#" and some letters, the autocorrect should provide some of the famous hash tags as autocorrect value.
BUT: I don't want to implement this for UITextField. I found some tutorials and blogs about a custom autocorrect for UITextField, but I want/must use a UITextView because the user should be able to enter multiline text. Also, the tutorials only provide some sort of autocorrect for single word values, like e-mail addresses and so on..
The autocorrect should work like the buildin autocorrect just like you know from the SMS app, but with my own set of autocorrect values.
Does somebody know a component or something like that which could me provide such a feature?
Thx in advance!
Upvotes: 1
Views: 660
Reputation: 3154
You can implement the UITextView delegate
method textView:shouldChangeTextInRange:replacementText:
to look for the #
: when you see it, display a subview at the location of the text with a table that contains the values you want to provide.
The location of the text can be ascertained using UITextInput protocol
methods. When a selection is made, replace the text in the range with the user's selection.
Upvotes: 1