3

I'm working on a app. it has texfields.What I want is when user type something in the textfield("as an exmple think user types letter 'y'") then below the text field , should show realtime all available names in start from 'y' as dropdown list. then user should be able to select one from it.then the selected items should display in the textfield.how can we do this.

Jobs
  • 269
  • 2
  • 6
  • 21
  • https://github.com/NeverHopeless/NHAutoCompleteTextField try this – Wolverine Dec 22 '15 at 09:26
  • http://www.raywenderlich.com/336/auto-complete-tutorial-for-ios-how-to-auto-complete-with-custom-values . get an idea. – Devendra Singh Dec 22 '15 at 09:27
  • I want to do this without using third party libraries. – Jobs Dec 22 '15 at 09:29
  • Then do something like this. Create a array with all your names. When you type something in text-field, at that time, filter the array, create a small table-view same width as text-field, and place it just below text-field., on table did select method, set name as a text-field text. – Wolverine Dec 22 '15 at 09:32
  • Use `UIToolBar` as `inputAccessoryView` of `UITextField`. Monitor changes and put suggestions in toolbar. – Cy-4AH Dec 22 '15 at 09:33
  • how can I do it, I'm new to ios.if you can please add code.it will help to others also Cy-4AH – Jobs Dec 23 '15 at 10:00

3 Answers3

1

Here is the basic idea for auto complete textfield utilising table view.

  1. create table view under textfield with hidden property set to Yes.
  2. set table view data source based on your unfiltered data.
  3. listen to textfield delegate and call function to filter your data source as well as hide/unhide table view based on textfield delegate.
  4. set textfield.text based on table view selection.
seto nugroho
  • 1,359
  • 1
  • 13
  • 20
1

Here you have another library that makes exactly what you need: https://github.com/apasccon/SearchTextField

pishke
  • 11
  • 1
0

This library should help (both Objc and Swift). As you type it filters results and displays a tableview of suitable results underneath.

https://github.com/gaurvw/MPGTextField

(sorry i couldn't add this as a comment)

Joe Benton
  • 3,703
  • 1
  • 21
  • 17
  • Just seen this has already been answered, might help: http://stackoverflow.com/questions/14960612/implementing-autocomplete-in-ios – Joe Benton Dec 22 '15 at 09:32