Is there a way to implement custom Auto-completion for a UITextView, say by giving it a NSDictionary or NSArray of Strings to watch out for?
Is there a way to implement custom Auto-completion for a UITextView, say by giving
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You would have to program it yourself. If you implement the UITextViewDelegate Protocol, the function
is called every time the user enters / deletes a character in the text view. So for example if the user enters a char ‘s’, then in this function you would check the array w the words you want to autocomplete to see if it should autocomplete.
CONDITIONS –
• If there is only one value that starts with ‘s’, autocomplete.
• If there are no values that start with ‘s’, or if there are multiple values that start with ‘s’, (ELSE) do not autocomplete.
I recommend that your autocomplete string array is sorted alphabetically, and that you keep a global variable that points to where you left off in the array. For example if the user enters ‘s’, and the first word with ‘s’ is in array index 5, then when the user enters another char, ‘u’ making the search string “su”, you should be able to remember to start in array index 5 to find the autocomplete string faster (and not iterate through useless data). I would use a C array for this, although an NSArray would work.