mnbayan / AutocompleteTextfieldSwift

Simple and straightforward sublass of UITextfield to manage string suggestions
MIT License
290 stars 66 forks source link

Text doesn't autocomplete? #16

Open surayashivji opened 8 years ago

surayashivji commented 8 years ago

I've implemented all that is required from this great add on, but for some reason, though the "autoCompleteStrings" appear in the table view for the text field, it doesn't actually autocomplete when I begin typing. is there a problem with my handleTextFieldInterfaces?

`private func handleTextFieldInterfaces() { self.chemicalAuto.onTextChange = {[weak self] text in

        print("Change")
        var keys = Array(DataSource.sharedManager.chemicalTable.keys)
        self!.chemicalAuto.autoCompleteStrings = keys
}

    self.chemicalAuto.onSelect =
    {
        [weak self] text, indexpath in

        print("select")
        var keys = Array(DataSource.sharedManager.chemicalTable.keys)
        self!.chemicalAuto.autoCompleteStrings = keys
    }
}`
mnbayan commented 8 years ago

Hi @surayashivji , i wasn't able to replicate this issue. But I have updated the code for the latest swift version. Please try if this will work for you first. Thank you.

wasimsandhu commented 8 years ago

I am having the same issue on my end.

mnbayan commented 8 years ago

@surayashivji @wasimsandhu I cannot replicate this issue on my end. Autocomplete strings are showing on table view when assigning strings to the autoCompleteStrings property.

However as to what is wrong on @surayashivji 's code snippet above, on self.chemicalAuto.onSelect please remove the ff:

var keys = Array(DataSource.sharedManager.chemicalTable.keys)
self!.chemicalAuto.autoCompleteStrings = keys

because this asks the library to once again reload and display another set of autocomplete strings