Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-Tag Auto Complete Textfield in Apple iOS development with Swift

So far I could accomplish Auto Complete feature on a Textfield UI in Xcode 6 for my iOS app, but my challenge is to make it take multiple tags and then show suggestion for each one. For example:

Enter "Ja" and it shows "Java" in the list, I choose that, type "," and it make it a tag, then I start typing "PH" and it shows "PHP", and I choose that and place another "," and so on. Just like the Jquery Auto-complete for multiple tags. Is there a way to accomplish this in iOS ?

Link to Jquery AutoComplete Plugin

like image 407
AlexCon Avatar asked Oct 27 '14 15:10

AlexCon


1 Answers

Use WSTagField library by whitesmith

Since you have completed the autocompletion logic. You just need to show the results in a UITableView. Then use WSTagField as shown below to show/hide suggestions table view.

let tagsField = WSTagsField()

// Events
tagsField.onDidAddTag = { field, tag in
    //Remove suggestions tableview from the view
    print("DidAddTag", tag.text)
}

tagsField.onDidChangeText = { _, text in
    //Add suggestions table to the view
}

tagsField.onDidChangeHeightTo = { _, height in
    //Update suggestions table frame to prevent tag field covering
}

tagsField.onValidateTag = { tag, tags in
    // validate tag here to match your tags list
}

enter image description here

like image 125
Husam Avatar answered Oct 08 '22 04:10

Husam