In a relatively simple way, I can think of, in order to achieve this functionality, it would add the appearance of a keyboard input that will offer suggestions.
You would not have to intervene in TextField yourself, and you would not need to include sentences in the rest of your application.
An auxiliary view can, for example, get a link to a text field and listen for input:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textChanged) name:UITextFieldTextDidChangeNotification object:textFieldWithSuggestions];
It will contain a method - (void) textChanged; in which you will have the opportunity to split the existing text into components, using a comma or any other character as a separator, and then use the last piece of text to perform a search for possible completions.
He can represent these sentences as a series of buttons, for example (perhaps even in side-scrolling scrolling to allow for a lot of sentences), and if someone is pushing, update the text of the text fields, replacing the last text segment with a filled line.
To track which button indicates which sentence, simply indicate the tags according to the index of the search results. Thus, you only need one method as the target for the buttons.
Toastor
source share