Skip to content

jkereako/AutocompleteTextField

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Autocomplete text field

A Swift version of HotelTonight's (RIP) HTAutocompleteTextField

This is not a framework. For something this simple, I think it's unnecessary to install this via CocoaPods or Carthage.

Usage

Copy AutocompleteTextField into your project. Change the class type of your textfield from UITextField to AutocompleteTextField in In Storyboard Builder or programatically. Define a data source struct and have it implement the protocol AutocompleteDataSource. Finally, wire everything together in your view controller's viewDidLoad() method:

import UIKit

class TableViewController: UITableViewController {

  @IBOutlet weak var nameField: AutocompleteTextField?

  override func viewDidLoad() {
    super.viewDidLoad()

    guard let name = nameField else {
      assertionFailure("Name field is nil. Did you forget to wire it up in Storyboard Builder?")
      return
    }
    
    // Set the datasource
    name.dataSource = DataSource()
    name.suggestionLabelPosition = CGPointMake(0, -0.5)
  }
}

About

A Swift version of HotelTonight's (RIP) autocomplete

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages